Imports System.Data
Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Globalization
Partial Class _DutySlip
Inherits System.Web.UI.Page
Dim cls As New Commfun.Comfunction
Dim strFormAccess As Array
Dim SrNo As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
txtCustDetails.Attributes.Add("readonly", "false")
Call clearAll()
Call fillGrid()
End If
End Sub
Private Sub clearAll()
cmbCustomer.SelectedValue = 0
End Sub
Private Sub fillGrid()
Dim strSQL As String
'Audit Columns
strSQL = "select DutyID,DutySlipNo from Dutymst order by DutyMst.DutySlipNo desc"
cls.FillDataGrid(griddata, strSQL)
lbl.Visible = True
gridData.Visible = True
pnlgrid.Visible = True
If griddata.Rows.Count = 0 Then
lbl.Text = "No record found"
lbl.ForeColor = Color.Red
btnAddNew.Visible = True
Else
lbl.Text = griddata.Rows.Count.ToString & " record(s) found"
lbl.ForeColor = Color.Black
btnAddNew.Visible = True
End If
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Try
Dim cmd As New SqlCommand
If cmbCustomer.SelectedValue = 0 Then
lblMsg.Text = "Please Select Customer"
lblMsg.Visible = True
lblMsg.ForeColor = Color.Red
imgWarn.Visible = True
Exit Sub
End If
If Trim(ltrMode.Text) = "APPEND_MODE" Then
cls.updateFormData("INSERT INTO DutyMst (CustId, CustDetail)values('" & cmbCustomer.SelectedValue & "','" & Trim(txtDutyCharge.Text.ToUpper) & "')")
lblMsg.Text = "Detail has been saved"
End If
Call fillGrid()
btnAddNew.Visible = True
pnlFormEdit.Visible = False
lblMsg.Visible = True
lblMsg.ForeColor = Color.Green
Call clearAll()
Catch ex As Exception
MyMessageBox(ex.Message)
End Try
End Sub
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
ltrMode.Text = "APPEND_MODE"
lblMsg.Text = ""
imgWarn.Visible = False
Call clearAll()
pnlFormEdit.Visible = True
btnCancel.Visible = True
btnSubmit.Visible = True
btnSubmit.Text = "Save"
gridData.Visible = False
pnlgrid.Visible = False
lbl.Visible = False
lblId.Visible = False
btnAddNew.Visible = False
txtCurrDate.Text = cls.getdateServer()
cls.FillCmb("SELECT CUSTNAME,CUSTID FROM CUSTOMERMST WHERE CUSTACTIVE='Y' ORDER BY CUSTNAME ", cmbCustomer, "--Select Customer--")
cmbCustomer.Focus()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
pnlFormEdit.Visible = False
lblMsg.Text = ""
lblMsg.Visible = True
imgWarn.Visible = False
btnSubmit.Text = "Update Details"
gridData.Visible = True
pnlgrid.Visible = True
lbl.Visible = True
lblId.Visible = True
ltrMode.Text = ""
btnAddNew.Visible = True
End Sub
Protected Sub gridData_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gridData.RowCommand
If e.CommandName = "SELECT" Then
ltrMode.Text = "UPDATE_MODE"
Call clearAll()
lblMsg.Text = ""
lbl.Text = ""
cls.FillCmb("SELECT CUSTNAME,CUSTID FROM CUSTOMERMST WHERE CUSTACTIVE='Y' ORDER BY CUSTNAME ", cmbCustomer, "--Select Customer--")
ltrDutyID.Text = griddata.DataKeys(e.CommandArgument).Value
cls.fillFormFields("SELECT DutyID,DutyMst.DutySlipNo as [lblSrNo],DutyMst.CustId as [cmbCustomer] DutyMst inner join CUSTOMERMST ON CUSTOMERMST.CUSTID=DutyMst.CustID WHERE (DutyID = " & Val(ltrDutyID.Text) & ")", pnlFormEdit)
btnSubmit.Text = "Update"
btnSubmit.Visible = True
btnCancel.Visible = True
gridData.Visible = False
pnlgrid.Visible = False
pnlFormEdit.Visible = True
End If
End Sub
Protected Sub cmbCustomer_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCustomer.SelectedIndexChanged
Try
If cmbCustomer.SelectedValue = 0 Then
lblMsg.Text = "Please Select Customer"
lblMsg.Visible = True
lblMsg.ForeColor = Color.Red
imgWarn.Visible = True
Exit Sub
Else
txtCustDetails.text = cls.getValue("SELECT CUSTNAME + CHAR(13)+CHAR(10) + CUSTADDR1 + CHAR(13)+CHAR(10) + CUSTADDR2 + CHAR(13)+CHAR(10) + CUSTADDR3 + CHAR(13)+CHAR(10) + Convert(VARCHAR,CUSTPINCODE) + CHAR(13)+CHAR(10) + CUSTPHONE + CHAR(13)+CHAR(10) + CUSTMOBILE as [txtCustMobile] FROM CUSTOMERMST WHERE CUSTID = " & cmbCustomer.SelectedValue & "")
lblMsg.Text = ""
lblMsg.Visible = True
imgWarn.Visible = False
End If
Catch ex As Exception
MyMessageBox(ex.Message)
End Try
End Sub
Protected Sub OnPaging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) Handles gridData.PageIndexChanging
griddata.PageIndex = e.NewPageIndex
fillGrid()
End Sub
Private Sub MyMessageBox(ByVal msg As String)
'ScriptManager.RegisterStartupScript(Page, Page.GetType(), "MyScript", "alert('" & msg & "');", True)
End Sub
End Class