I am using gridview and in that I 8 link button. Now on clck Link button only this link buton are disable others are enabled and this link button through i insert data
code
html code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="reports.aspx.vb" Inherits="ACC_reports" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript" src="../Scripts/calander.js"></script>
</head>
<body leftmargin="0" topmargin="0" bottommargin="0" rightmargin="0" onkeypress="CP()">
<span id="spn1" style="display:none;removed0px;removed:absolute"></span>
<form id="form1" runat="server">
<div>
<table id="tblHeader" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:<%=db.headerBG%>;color:<%=db.headerColor%>;font-family:<%=db.headerText%>;font-weight:<%=db.headerWeight%>;font-style:<%=db.headerStyle%>;text-decoration:<%=db.headerDecoration%>;font-size:<%=db.headerSize%>px;text-align:<%=db.headerAlignment%>">
<tr>
<td>Reports</td>
</tr>
</table>
<table width="100%" border="1" cellpadding="0" cellspacing="0" id="tblForm" style="background-color:<%=db.formBG%>;color:<%=db.formColor%>;font-family:<%=db.formText%>;font-weight:<%=db.formWeight%>;font-style:<%=db.formStyle%>;text-decoration:<%=db.formDecoration%>;font-size:<%=db.formSize%>px;text-align:<%=db.formAlignment%>">
<tr>
<td width="25%">Select Executive/SiteOffice</td>
<td><asp:DropDownList ID="Drpoption" runat="server" AutoPostBack="true">
<asp:ListItem Value="0">[Select]</asp:ListItem>
<asp:ListItem Value="1">Executive</asp:ListItem>
<asp:ListItem Value="2">SiteOffice</asp:ListItem>
</asp:DropDownList></td>
<td width="25%"><asp:Label ID="lblselect" runat="server"></asp:Label></td>
<td><asp:DropDownList ID="drpexe" runat="server" Visible="false"></asp:DropDownList></td>
</tr>
<tr>
<td colspan="2">Duration From<asp:TextBox ID="txtfrmDt" runat="server" onpaste="return false;" onkeydown="return checkKey()" oncut="return false;" ToolTip="From Date" MaxLength="40"></asp:TextBox>
<img src="../Images/calander.gif" runat="server" id="img1" önclick="showTBL('txtfrmDt')" alt=""/></td>
<td colspan="2">To <asp:TextBox ID="txtToDt" runat="server" onpaste="return false;" onkeydown="return checkKey()" oncut="return false;" ToolTip="To Date" MaxLength="40"></asp:TextBox>
<img src="../Images/calander.gif" runat="server" id="img2" önclick="showTBL('txtToDt')" alt=""/></td>
</tr>
<tr style="background-color:<%=db.headerBG%>;color:<%=db.headerColor%>;font-family:<%=db.headerText%>;font-weight:<%=db.headerWeight%>;font-style:<%=db.headerStyle%>;text-decoration:<%=db.headerDecoration%>;font-size:<%=db.headerSize%>px;text-align:<%=db.headerAlignment%>">
<td colspan="4"><asp:Button ID="btnsubmit" runat="server" Text="Show" /></td>
</tr>
<tr>
<td colspan="4">
<asp:GridView ID="gvcomm" runat="server" Width="100%" AutoGenerateColumns="false" ShowFooter="true" DataKeyNames="orderitemid">
<Columns>
<asp:TemplateField HeaderText="#">
<ItemTemplate>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<%#Eval("Odate") %>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Order Code">
<ItemTemplate>
<%#Eval("orderid")%>/ <%#Eval("ordercode")%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Prod.">
<ItemTemplate>
<%#Eval("pname")%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Qty.">
<ItemTemplate>
<%#eval("quan") %>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<FooterTemplate>
<asp:Label ID="lbltotal" Text="Total" runat="server"></asp:Label>
</FooterTemplate>
<FooterStyle HorizontalAlign="center" Font-Bold="true" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Rate">
<ItemTemplate>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Disc.">
<ItemTemplate>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Action For Order Execution Report">
<ItemTemplate>
<asp:LinkButton ID="lnkShare" runat="server" CommandName="Edit">S</asp:LinkButton>//
<asp:LinkButton ID="lnkDeny" runat="server" CommandName="Update">D</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" BackColor="DarkGray" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Ord. Exe.">
<ItemTemplate>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" BackColor="DarkGray" />
<FooterTemplate>
<asp:Label ID="lbltot" runat="server"></asp:Label>
</FooterTemplate>
<FooterStyle HorizontalAlign="center" Font-Bold="true" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Action For Sales Commission Report">
<ItemTemplate>
<asp:LinkButton ID="lnkShare1" runat="server" CommandName="Edit">S</asp:LinkButton>//
<asp:LinkButton ID="lnkDeny1" runat="server" CommandName="Update">D</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" BackColor="Silver" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Comm.">
<ItemTemplate>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" BackColor="Silver"/>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action For Proof Execution Charge Report">
<ItemTemplate>
<asp:LinkButton ID="lnkShare2" runat="server" CommandName="Edit">S</asp:LinkButton>//
<asp:LinkButton ID="lnkDeny2" runat="server" CommandName="Update">D</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" BackColor="DarkGray" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Proof Exe.">
<ItemStyle HorizontalAlign="Center" BackColor="DarkGray" />
<FooterTemplate>
<asp:Label ID="lbltot1" runat="server"></asp:Label>
</FooterTemplate>
<FooterStyle Font-Bold="true" HorizontalAlign="center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Action For Composition Charge Report">
<ItemTemplate>
<asp:LinkButton ID="lnkShare3" runat="server" CommandName="Edit">S</asp:LinkButton>//
<asp:LinkButton ID="lnkDeny3" runat="server" CommandName="Update">D</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" BackColor="Silver" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Comp.">
<ItemTemplate>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" BackColor="Silver" />
<FooterTemplate>
<asp:Label ID="lbltot2" runat="server"></asp:Label>
</FooterTemplate>
<FooterStyle HorizontalAlign="center" Font-Bold="true" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Invoice">
<ItemTemplate>
<a href="java<!-- no -->script:Add_Member=window.open('summaryinvoice.aspx?type=sales&&orderid=<%#Eval("orderid") %> ','Add_Member','width=800,height=400,top=170,left=210,scrollbars=yes');Add_Member.focus();">Orig.</a> //
<a href="java<!-- no -->script:Add_Member=window.open('perfomainvoice.aspx?type=sales&&orderid=<%#Eval("orderid") %> ','Add_Member','width=800,height=400,top=170,left=210,scrollbars=yes');Add_Member.focus();">Perf.</a>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<HeaderStyle HorizontalAlign="center" />
</asp:GridView>
</td>
</tr>
</table>
</form>
</body>
</html>
vb.net code
Partial Class ACC_reports
Inherits System.Web.UI.Page
Public db As New general
Dim dr, dr1 As Object
Dim cnt As Integer
Dim ds As New Data.DataSet
Dim composition As Double
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If db.checkUser(LCase(Application("users")), LCase(Session("loginName")), LCase(Session.SessionID)) <> "OK" Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "ddd", "<script>window.parent.location='../timeout.htm';</script>")
End If
db.setLayout(Session("uId"))
If Not IsPostBack Then
db.fillCombo(drpexe, "employee", "empname", "empid", " where 1=2")
End If
End Sub
Protected Sub drpexe_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drpexe.SelectedIndexChanged
End Sub
Protected Sub Drpoption_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Drpoption.SelectedIndexChanged
If Drpoption.SelectedValue = "1" Then
drpexe.Visible = False
ElseIf Drpoption.SelectedValue = "2" Then
lblselect.Text = "Select Site Office"
db.fillCombo(drpexe, "siteofficemaster", "sitecode", "siteoffid", " where siteoffid in (select executiveid from salesorder where exetype=2)")
drpexe.Visible = True
End If
gvcomm.DataSource = Nothing
gvcomm.DataBind()
End Sub
Private Sub Show()
Dim status As String = ""
If txtfrmDt.Text <> "" And txtToDt.Text = "" Then status = status & " and convert(smalldatetime,a.dt1) = convert(smalldatetime,'" & txtfrmDt.Text & "')"
If txtfrmDt.Text <> "" And txtToDt.Text <> "" Then status = status & " and convert(smalldatetime,a.dt1) between convert(smalldatetime,'" & txtfrmDt.Text & "') and convert(smalldatetime,'" & txtToDt.Text & "')"
If txtfrmDt.Text = "" And txtToDt.Text = "" Then status = status & ""
If Drpoption.SelectedValue = "1" Then
Dim str As String = "select b.*,a.orderid,a.ordercode,productname as pname,b.qty as quan,a.enqdate as Odate from salesorder as a,salesorderitems as b where a.orderid=b.orderid and exetype=1 " & status & " order by convert(smalldatetime,a.enqdate)"
db.fillReader(str, dr)
ElseIf Drpoption.SelectedValue = "2" Then
Dim str As String = "select b.*,a.orderid,a.ordercode,productname as pname,b.qty as quan,a.enqdate as Odate from salesorder as a,salesorderitems as b where a.orderid=b.orderid and exetype=2 and executiveid=" & drpexe.SelectedValue & " " & status & " order by convert(smalldatetime,a.enqdate)"
db.fillReader(str, dr)
End If
gvcomm.DataSource = dr
gvcomm.DataBind()
End Sub
Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click
Show()
End Sub
Protected Sub gvcomm_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvcomm.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(0).Text = e.Row.RowIndex + 1
cnt = cnt + 1
Dim com As Double
Dim commission As Double = 0
Dim comid As Integer
Dim compid As Integer
Dim comm As Double
Dim strId As String = gvcomm.DataKeys(e.Row.RowIndex).Value.ToString()
Dim str As String = "select * from salesorderitems where orderitemid=" & strId
db.fillReader(str, dr)
While dr.read()
e.Row.Cells(4).Text = dr("qty")
e.Row.Cells(5).Text = dr("priceINR")
e.Row.Cells(6).Text = dr("distype") & "-" & dr("discount")
If Drpoption.SelectedValue = "1" Then
e.Row.Cells(8).Text = "15"
e.Row.Cells(12).Text = "7"
If dr("qty") >= 100 Then
comid = db.getFieldValue("productmaster", "productid", strId, "salescomminr", True, True)
If dr("discount") > 0 Then
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "commwd", True, True)
Else
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "comm", True, True)
End If
commission = com
e.Row.Cells(10).Text = commission
Else
e.Row.Cells(10).Text = "0"
End If
ElseIf Drpoption.SelectedValue = "2" Then
e.Row.Cells(8).Text = "50"
e.Row.Cells(12).Text = "7"
comid = db.getFieldValue("productmaster", "productid", strId, "salescommper", True, True)
If dr("discount") > 0 Then
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "commwd", True, True)
Else
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "comm", True, True)
End If
commission = (dr("priceinr") * dr("qty") * com / 100)
e.Row.Cells(10).Text = commission
Else
e.Row.Cells(10).Text = "0"
End If
compid = db.getFieldValue("productmaster", "productid", strId, "compid", True, True)
comm = db.getFieldValue("compchargemaster", "compid", compid, "priceinr", True, True)
composition = composition + comm
e.Row.Cells(14).Text = comm
End While
Dim Share As LinkButton = CType(e.Row.FindControl("lnkShare"), LinkButton)
Dim Deny As LinkButton = CType(e.Row.FindControl("lnkDeny"), LinkButton)
Dim Share1 As LinkButton = CType(e.Row.FindControl("lnkShare2"), LinkButton)
Dim Deny1 As LinkButton = CType(e.Row.FindControl("lnkDeny2"), LinkButton)
Dim Share2 As LinkButton = CType(e.Row.FindControl("lnkShare1"), LinkButton)
Dim Deny2 As LinkButton = CType(e.Row.FindControl("lnkDeny1"), LinkButton)
Dim Share3 As LinkButton = CType(e.Row.FindControl("lnkShare3"), LinkButton)
Dim Deny3 As LinkButton = CType(e.Row.FindControl("lnkDeny3"), LinkButton)
If db.isExists("commissionPostMaster", "orderItemID", strId, True, " and commtype='Order Execution'") = True Then
Share.Enabled = False
Deny.Enabled = False
e.Row.Cells(8).Text = e.Row.Cells(8).Text & "/" & db.getFieldValue("commissionPostMaster", "orderItemId", strId, "amount", True, True, " and plantid=" & Session("plantId") & " and commtype='Order Execution'")
If db.getFieldValue("commissionpostmaster", "orderItemId", strId, "discounttype", True, False, " and commtype='Order Execution'") = "No" Then
e.Row.Cells(8).ForeColor = Drawing.Color.Maroon
e.Row.Cells(8).Font.Bold = True
End If
End If
If db.isExists("commissionPostMaster", "orderItemID", strId, True, " and commtype='Proof Execution'") = True Then
Share1.Enabled = False
Deny1.Enabled = False
e.Row.Cells(12).Text = e.Row.Cells(12).Text & "/" & db.getFieldValue("commissionPostMaster", "orderItemId", strId, "amount", True, True, " and plantid=" & Session("plantId") & " and commtype='Proof Execution'")
If db.getFieldValue("commissionpostmaster", "orderItemId", strId, "discounttype", True, False, " and commtype='Proof Execution'") = "No" Then
e.Row.Cells(12).ForeColor = Drawing.Color.Maroon
e.Row.Cells(12).Font.Bold = True
End If
End If
If db.isExists("commissionPostMaster", "orderItemID", strId, True, " and commtype='Sales Commission'") = True Then
Share2.Enabled = False
Deny2.Enabled = False
e.Row.Cells(10).Text = e.Row.Cells(10).Text & "/" & db.getFieldValue("commissionPostMaster", "orderItemId", strId, "amount", True, True, " and plantid=" & Session("plantId") & " and commtype='Sales Commission'")
If db.getFieldValue("commissionpostmaster", "orderItemId", strId, "discounttype", True, False, " and commtype='Sales Commission'") = "No" Then
e.Row.Cells(10).ForeColor = Drawing.Color.Maroon
e.Row.Cells(10).Font.Bold = True
End If
End If
If db.isExists("commissionPostMaster", "orderItemID", strId, True, " and commtype='Composition Commission'") = True Then
Share3.Enabled = False
Deny3.Enabled = False
e.Row.Cells(14).Text = e.Row.Cells(14).Text & "/" & db.getFieldValue("commissionPostMaster", "orderItemId", strId, "amount", True, True, " and plantid=" & Session("plantId") & " and commtype='Composition Commission'")
If db.getFieldValue("commissionpostmaster", "orderItemId", strId, "discounttype", True, False, " and commtype='Composition Commission'") = "No" Then
e.Row.Cells(14).ForeColor = Drawing.Color.Maroon
e.Row.Cells(14).Font.Bold = True
End If
End If
dr.close()
End If
If e.Row.RowType = DataControlRowType.Footer Then
If Drpoption.SelectedValue = "1" Then
Dim lbl As Label = CType(e.Row.FindControl("lbltot"), Label)
Dim lbl1 As Label = CType(e.Row.FindControl("lbltot1"), Label)
Dim lbl2 As Label = CType(e.Row.FindControl("lbltot2"), Label)
Dim b As Double = 15 * cnt
Dim b1 As Double = 7 * cnt
Dim b2 As Double = composition
lbl.Text = CDbl(b)
lbl1.Text = CDbl(b1)
lbl2.Text = CDbl(b2)
Else
Dim lbl As Label = CType(e.Row.FindControl("lbltot"), Label)
Dim lbl1 As Label = CType(e.Row.FindControl("lbltot1"), Label)
Dim lbl2 As Label = CType(e.Row.FindControl("lbltot2"), Label)
Dim b As Double = 50 * cnt
Dim b1 As Double = 7 * cnt
Dim b2 As Double = composition
lbl.Text = CDbl(b)
lbl1.Text = CDbl(b1)
lbl2.Text = CDbl(b2)
End If
End If
End Sub
Protected Sub showshare(ByVal sender As Object, ByVal e As System.EventArgs)
Dim transType As String = ""
Dim com As Double
Dim commission As Double = 0
Dim comid As Integer
Dim strId As String = gvcomm.DataKeys(e.ToString()).Value.ToString()
Dim commid As Integer = db.getMaxId("commissionPostMaster", "commid")
Dim orderId As String = ""
Dim ordercode As String = ""
Dim orderItemId As String = ""
Dim disType As String = ""
Dim discount As String = ""
Dim Odate As String = ""
Dim priceINR As String = ""
Dim qty As String = ""
Dim a As String
Dim b As String
Dim strqry As String = "select * from salesorderitems where orderitemid=" & strId
db.fillReader(strqry, dr)
While dr.read()
orderId = dr("orderId")
ordercode = dr("orderCode")
orderItemId = strId
disType = dr("distype")
discount = dr("discount")
Odate = db.getFieldValue("salesOrder", "orderId", orderId, "enqdate", True)
priceINR = dr("priceINR")
qty = dr("qty")
End While
dr.close()
Dim dt = Date.Now.ToString("dd-MMM-yyyy")
If Drpoption.SelectedValue = "1" Then
com = "15"
ElseIf Drpoption.SelectedValue = "2" Then
com = "50"
End If
commission = com
transType = "INR"
Dim str As String = "insert into commissionPostMaster values(" & commid & "," & Session("plantId") & "," & _
orderId & "," & orderItemId & ",'" & ordercode & "','Order Execution',0,0,'" & transType & "'," & _
commission & ",'" & Odate & "','Yes'," & Session("uID") & ",'" & dt & "')"
db.executeQuery(str)
End Sub
Protected Sub gvcomm_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvcomm.RowEditing
gvcomm.EditIndex = e.NewEditIndex
Dim transType As String = ""
Dim com As Double
Dim commission As Double = 0
Dim comid As Integer
Dim strId As String = gvcomm.DataKeys(e.NewEditIndex).Value.ToString()
Dim commid As Integer = db.getMaxId("commissionPostMaster", "commid")
Dim orderId As String = ""
Dim ordercode As String = ""
Dim orderItemId As String = ""
Dim disType As String = ""
Dim discount As String = ""
Dim Odate As String = ""
Dim priceINR As String = ""
Dim qty As String = ""
Dim strqry As String = "select * from salesorderitems where orderitemid=" & strId
db.fillReader(strqry, dr)
While dr.read()
orderId = dr("orderId")
ordercode = dr("orderCode")
orderItemId = strId
disType = dr("distype")
discount = dr("discount")
Odate = db.getFieldValue("salesOrder", "orderId", orderId, "enqdate", True)
priceINR = dr("priceINR")
qty = dr("qty")
End While
dr.close()
Dim dt = Date.Now.ToString("dd-MMM-yyyy")
Dim Share As LinkButton = CType(gvcomm.Rows(e.NewEditIndex).FindControl("lnkShare"), LinkButton)
Dim Share1 As LinkButton = CType(gvcomm.Rows(e.NewEditIndex).FindControl("lnkShare2"), LinkButton)
Dim Share2 As LinkButton = CType(gvcomm.Rows(e.NewEditIndex).FindControl("lnkShare1"), LinkButton)
Dim Share3 As LinkButton = CType(gvcomm.Rows(e.NewEditIndex).FindControl("lnkShare3"), LinkButton)
AddHandler Share.Click, AddressOf showshare
If Drpoption.SelectedValue = "1" Then
com = "15"
ElseIf Drpoption.SelectedValue = "2" Then
com = "50"
End If
commission = com
transType = "INR"
Dim str As String = "insert into commissionPostMaster values(" & commid & "," & Session("plantId") & "," & _
orderId & "," & orderItemId & ",'" & ordercode & "','Order Execution',0,0,'" & transType & "'," & _
commission & ",'" & Odate & "','Yes'," & Session("uID") & ",'" & dt & "')"
db.executeQuery(str)
commission = "7"
transType = "INR"
Dim str1 As String = "insert into commissionPostMaster values(" & commid & "," & Session("plantId") & "," & _
orderId & "," & orderItemId & ",'" & ordercode & "','Proof Execution',0,0,'" & transType & "'," & _
commission & ",'" & Odate & "','Yes'," & Session("uID") & ",'" & dt & "')"
db.executeQuery(str1)
If Drpoption.SelectedValue = "1" Then
If qty >= 100 Then
comid = db.getFieldValue("productmaster", "productid", strId, "salescomminr", True, True)
If discount > 0 Then
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "commwd", True, True)
Else
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "comm", True, True)
End If
commission = com
Else
commission = "0"
End If
transType = "INR"
ElseIf Drpoption.SelectedValue = "2" Then
comid = db.getFieldValue("productmaster", "productid", strId, "salescommper", True, True)
If discount > 0 Then
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "commwd", True, True)
Else
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "comm", True, True)
End If
commission = (priceINR * qty * com / 100)
If disType = "INR" Then
commission = commission - (discount * qty * 0.5)
ElseIf disType = "PER" Then
commission = commission - (((priceINR * qty * discount) / 100) / 2)
End If
transType = "PER"
Else
commission = "0"
End If
Dim str2 As String = "insert into commissionPostMaster values(" & commid & "," & Session("plantId") & "," & _
orderId & "," & orderItemId & ",'" & ordercode & "','Sales Commission'," & Drpoption.SelectedValue & "," & _
drpexe.SelectedValue & ",'" & transType & "'," & commission & ",'" & Odate & "','Yes'," & Session("uID") & ",'" & dt & "')"
db.executeQuery(str2)
comid = db.getFieldValue("productmaster", "productid", strId, "salescomminr", True, True)
If discount > 0 Then
com = db.getFieldValue("compchargemaster", "compid", comid, "priceinr", True, True)
Else
com = db.getFieldValue("compchargemaster", "compid", comid, "priceinr", True, True)
End If
commission = com
transType = "INR"
Dim str3 As String = "insert into commissionPostMaster values(" & commid & "," & Session("plantId") & "," & _
orderId & "," & orderItemId & ",'" & ordercode & "','Composition Commission',0,0,'" & transType & "'," & _
commission & ",'" & Odate & "','Yes'," & Session("uID") & ",'" & dt & "')"
db.executeQuery(str3)
Show()
End Sub
Protected Sub gvcomm_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvcomm.RowUpdating
Dim transType As String = ""
Dim com As Double
Dim commission As Double = 0
Dim comid As Integer
Dim strId As String = gvcomm.DataKeys(e.RowIndex).Value.ToString()
Dim commid As Integer = db.getMaxId("commissionPostMaster", "commid")
Dim orderId As String = ""
Dim ordercode As String = ""
Dim orderItemId As String = ""
Dim disType As String = ""
Dim discount As String = ""
Dim Odate As String = ""
Dim priceINR As String = ""
Dim qty As String = ""
Dim Deny As LinkButton = CType(gvcomm.Rows(e.RowIndex).FindControl("lnkDeny"), LinkButton)
Dim Deny1 As LinkButton = CType(gvcomm.Rows(e.RowIndex).FindControl("lnkDeny2"), LinkButton)
Dim Deny2 As LinkButton = CType(gvcomm.Rows(e.RowIndex).FindControl("lnkDeny1"), LinkButton)
Dim Deny3 As LinkButton = CType(gvcomm.Rows(e.RowIndex).FindControl("lnkDeny3"), LinkButton)
Dim strqry As String = "select * from salesorderitems where orderitemid=" & strId
db.fillReader(strqry, dr)
While dr.read()
orderId = dr("orderId")
ordercode = dr("orderCode")
orderItemId = strId
disType = dr("distype")
discount = dr("discount")
Odate = db.getFieldValue("salesOrder", "orderId", orderId, "enqdate", True)
priceINR = dr("priceINR")
qty = dr("qty")
End While
dr.close()
Dim dt = Date.Now.ToString("dd-MMM-yyyy")
If Drpoption.SelectedValue = "1" Then
com = "0"
ElseIf Drpoption.SelectedValue = "2" Then
com = "0"
End If
transType = "INR"
Dim str As String = "insert into commissionPostMaster values(" & commid & "," & Session("plantId") & "," & _
orderId & "," & orderItemId & ",'" & ordercode & "','Order Execution',0,0,'" & transType & "'," & _
commission & ",'" & Odate & "','No'," & Session("uID") & ",'" & dt & "')"
db.executeQuery(str)
If qty >= 100 Then
comid = db.getFieldValue("compchargemaster", "compid", comid, "priceinr", True, True)
commission = "0"
Else
commission = "0"
End If
transType = "INR"
Dim str1 As String = "insert into commissionPostMaster values(" & commid & "," & Session("plantId") & "," & _
orderId & "," & orderItemId & ",'" & ordercode & "','Proof Execution',0,0,'" & transType & "'," & _
commission & ",'" & Odate & "','No'," & Session("uID") & ",'" & dt & "')"
db.executeQuery(str1)
If Drpoption.SelectedValue = "1" Then
If qty >= 100 Then
comid = db.getFieldValue("productmaster", "productid", strId, "salescomminr", True, True)
commission = "0"
Else
commission = "0"
End If
transType = "INR"
ElseIf Drpoption.SelectedValue = "2" Then
comid = db.getFieldValue("productmaster", "productid", strId, "salescommper", True, True)
If discount > 0 Then
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "commwd", True, True)
Else
com = db.getFieldValue("salescommissionmaster", "salescommid", comid, "comm", True, True)
End If
commission = (priceINR * qty * com / 100)
If disType = "INR" Then
commission = commission - (discount * qty)
ElseIf disType = "PER" Then
commission = commission - (((priceINR * qty * discount) / 100))
End If
transType = "PER"
Else
commission = "0"
End If
Dim str2 As String = "insert into commissionPostMaster values(" & commid & "," & Session("plantId") & "," & _
orderId & "," & orderItemId & ",'" & ordercode & "','Sales Commission'," & Drpoption.SelectedValue & "," & _
drpexe.SelectedValue & ",'" & transType & "'," & commission & ",'" & Odate & "','No'," & Session("uID") & ",'" & dt & "')"
db.executeQuery(str2)
If qty >= 100 Then
comid = db.getFieldValue("compchargemaster", "compid", comid, "priceinr", True, True)
commission = "0"
Else
commission = "0"
End If
transType = "INR"
Dim str3 As String = "insert into commissionPostMaster values(" & commid & "," & Session("plantId") & "," & _
orderId & "," & orderItemId & ",'" & ordercode & "','Composition Commission',0,0,'" & transType & "'," & _
commission & ",'" & Odate & "','No'," & Session("uID") & ",'" & dt & "')"
db.executeQuery(str3)
Show()
End Sub
End Class