  | 
              
	              
	                
  
    |   | 
   
  
    
        
        .NET พอจะมีตัวอย่างหน้าฟอร์มการปันผลให้กับสมาชิก สหกรณ์ พร้อมโค๊ด     | 
   
  
    |   | 
   
 
 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ต้องการหน้าจอแบบไหนก็ลองวาด ๆ Storyboard ลองกระดาษ แล้วค่อยมาเขียนโปรแกรมครับ                        
               
               | 
             
            
              
			  			  
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-09 07:56:02 | 
                        By :
                            mr.win | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                   
ประมาณนี้นะคะ อยากได้สูตรการคูณ แล้วให้ค่าไปโชว์อีก textbox หนึ่งค่ะ ขอโค๊ดตัวอย่างได้มั้ยคะ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-09 19:19:04 | 
                        By :
                            Aonaka | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ตัวนี้เป็นโค๊ดเเบบมั่วๆนะคะ ลองหาก็อบมาค่ะ ต้องเเก้ส่วนไหนบ้างคะถึงจะคำนวณได้ 
Code (VB.NET) 
Imports System.Data.SqlClient
Public Class frmDiv
    Dim conn As SqlConnection
    Dim com As SqlCommand
    Dim ap As SqlDataAdapter
    Dim ds As New DataSet()
    Dim dt As New DataTable
    Dim dr As SqlDataReader
    Private Property Button1_Click As Integer
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        frmMain.Show()
        Me.Close()
    End Sub
    Private Sub frmDiv_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conn = New SqlConnection()
        With conn
            If .State = ConnectionState.Open Then .Close()
            .ConnectionString = Database.strConn.ToString
            .Open()
        End With
        Dim sql5 As String = "SELECT รหัสปันผล FROM ปันผล"
        com = New SqlCommand
        With com
            .CommandType = CommandType.Text
            .CommandText = sql5
            .Connection = conn
            .Parameters.Clear()
            .Parameters.Add("รหัสปันผล", SqlDbType.VarChar).Value = "T001"
            dr = .ExecuteReader()
            If dr.HasRows Then
                dt = New DataTable
                dt.Load(dr)
                Dim q = dt.Rows(dt.Rows.Count - 1).Item("รหัสปันผล").ToString
                dt.Clear()
                dr.Close()
                conn.Close()
                Dim aa = q.Split("T00")
                Dim numm = CInt(aa(1)) + 1
            Else
                conn.Close()
            End If
        End With
        ShowData()
    End Sub
    Private Sub Showmember()
        Dim sql2 As String = String.Empty
        conn.Open()
        sql2 = "select * from member"
        Dim ds = New DataSet
        Dim da = New SqlClient.SqlDataAdapter(sql2, conn)
        da.Fill(ds, "member")
        'If ds.tables("member").rows.count <> 0 Then 
        DataGridView1.DataSource = ds.Tables("member")
        'End If 
        conn.Close()
        Call Format_DataGridView1()
    End Sub
    Private Sub Format_DataGridView1()
        With DataGridView1
            If .RowCount > 0 Then
                .Columns(0).HeaderText = "รหัสสมาชิก"
                .Columns(1).HeaderText = "คำนำหน้าชื่อ"
                .Columns(2).HeaderText = "ชื่อสมาชิก"
                .Columns(3).HeaderText = "เงินปันผลตามจำนวนหุ้น"
                .Columns(4).HeaderText = "เงินปันผลตามยอดซื้อ"
                .Columns(5).HeaderText = "รวมเงินปันผลสุทธิ"
                .Columns(6).HeaderText = "ยอดซื้อ"
                .Columns(0).DataPropertyName = "m_id"
                .Columns(1).DataPropertyName = "m_sex"
                .Columns(2).DataPropertyName = "m_name"
                .Columns(3).DataPropertyName = "Div_share"
                .Columns(4).DataPropertyName = "Div_purchase"
                .Columns(5).DataPropertyName = "T_net_div"
                .Columns(6).DataPropertyName = "purchase"
                .Columns(0).Width = 80
                .Columns(1).Width = 80
                .Columns(2).Width = 80
                .Columns(3).Width = 80
                .Columns(4).Width = 80
                .Columns(5).Width = 80
                .Columns(6).Width = 80
               
            End If
        End With
    End Sub
    Private Sub ShowData()
        ds.Clear()
        Dim sql As String = "Select * From ปันผล where รหัสปันผล='" & TextBox14.Text.Trim & "'"
        com = New SqlCommand(sql, conn)
        ap = New SqlDataAdapter(com)
        ap.Fill(ds, "ปันผล")
        DataGridView2.DataSource = ds.Tables("ปันผล")
        DataGridView2.Columns.Item(0).Width = 110
        DataGridView2.Columns.Item(1).Width = 230
        DataGridView2.Columns.Item(2).Width = 120
        DataGridView2.Columns.Item(3).Width = 120
        DataGridView2.Columns.Item(4).Width = 140
        DataGridView2.Columns.Item(5).Width = 140
        DataGridView2.Columns.Item(6).Width = 140
        conn.Close()
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        With conn
            With conn
                If .State = ConnectionState.Open Then .Close()
            End With
            conn.Open()
            Dim sql5 As String = "SELECT รหัสปันผล FROM ปันผล"
            com = New SqlCommand
            With com
                .CommandType = CommandType.Text
                .CommandText = sql5
                .Connection = conn
                .Parameters.Clear()
                .Parameters.Add("รหัสปันผล", SqlDbType.VarChar).Value = "T001"
                dr = .ExecuteReader()
                If dr.HasRows Then
                    dt = New DataTable
                    dt.Load(dr)
                    Dim q = dt.Rows(dt.Rows.Count - 1).Item("รหัสปันผล").ToString
                    dt.Clear()
                    dr.Close()
                    conn.Close()
                    Dim aa = q.Split("T00")
                    Dim numm = CInt(aa(1)) + 1
                    TextBox14.Text = "T00" & numm
                Else
                    TextBox14.Text = "T001"
                    conn.Close()
                End If
            End With
            ShowData()
        End With
    End Sub
    Private Sub Clear()
        TextBox4.Clear()
        TextBox8.Clear()
        TextBox10.Clear()
        TextBox9.Clear()
        TextBox11.Clear()
        TextBox4.Focus()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Clear()
    End Sub
    Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
    End Sub
    Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
    End Sub
    Private Sub TextBox10_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox10.TextChanged
    End Sub
    Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
    End Sub
    Private Sub TextBox11_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox11.TextChanged
    End Sub
    Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub
    Private Sub GroupBox3_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox3.Enter
    End Sub
    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
    End Sub
    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub
    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    End Sub
    Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click
        Dim a As Single
        Dim aa As Single = TextBox1.Text
        Dim f As Single = TextBox7.Text
        Dim x As Single = TextBox5.Text
        Dim y As Single = TextBox4.Text
        Dim z As Single = TextBox13.Text
        a = aa / 100
        f = aa * y
        z = f / x
        Format$(Math.Floor(a), "######0.00")
        Dim b As Single
        Dim bb As Single = TextBox8.Text
        Dim bbb As Single = TextBox6.Text
        b = (bb / 100)
        bbb = y * bb
        TextBox10.Text = bbb / 3
        TextBox10.Text = Format$(Math.Floor(b), "######0.00")
        Dim c As Single
        Dim cc As Single = TextBox11.Text
        Dim ccc As Single = TextBox12.Text
        Dim d As Single = TextBox2.Text
        c = (cc / 100)
        ccc = d * cc
        TextBox9.Text = Format$(Math.Floor(b), "######%")
    End Sub
    Private Sub TextBox14_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox14.TextChanged
    End Sub
    Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
        conn.Open()
        Dim sql5 As String = "SELECT * FROM member Where m_id ='" & txtSearch.Text.Trim & "'"
        com = New SqlCommand
        With com
            .CommandType = CommandType.Text
            .CommandText = sql5
            .Connection = conn
            .Parameters.Clear()
            .Parameters.Add("m_id", SqlDbType.VarChar).Value = txtSearch.Text.Trim
            dr = .ExecuteReader()
        End With
        If dr.HasRows Then
            dt = New DataTable
            dt.Load(dr)
            TextBox16.Text = dt.Rows(dt.Rows.Count - 1).Item("m_id").ToString
            TextBox15.Text = dt.Rows(dt.Rows.Count - 1).Item("m_sex").ToString & dt.Rows(dt.Rows.Count - 1).Item("m_name").ToString
            dt.Clear()
            dr.Close()
            conn.Close()
        Else
            MessageBox.Show("ไม่พบรหัสสมาชิกนี้", "การตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Information)
            dr.Close()
            conn.Close()
        End If
        TextBox15.Enabled = True
        TextBox16.Enabled = True
        Button3.Enabled = True
        Button2.Enabled = True
        Button8.Enabled = True
    End Sub
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    End Sub
End Class
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-09 19:48:50 | 
                        By :
                            Aonaka | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 เด่วนะ ครับ                            
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-09 19:57:33 | 
                        By :
                            leksoft | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ค่ะ อิอิ                         
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-09 20:50:00 | 
                        By :
                            Aonaka | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 พี่ลง sql server ยังบ่ได้เลยยยย                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-10 03:12:29 | 
                        By :
                            leksoft | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
      		  
	
     | 
   
 
                 |