public void BindCustomerComboBox()
 {
     try
     {
         /*****************      Bind the Customer Combo*******************/
         clsCustomerMaster objLoad = new clsCustomerMaster();
         objLoad.Mode      = "SELECTALL";
         objLoad.CompanyID = cId;
         var       dsCustomer = objLoad.GetAllCustomer();
         DataTable dtCustomer = dsCustomer.Tables[0];
         DataRow   dr         = dtCustomer.NewRow();
         dr["CustomerID"]   = "0";
         dr["CustomerName"] = "All";
         dtCustomer.Rows.InsertAt(dr, 0);
         cmbCustomer.DataSource    = dtCustomer;
         cmbCustomer.DisplayMember = "CustomerName";
         cmbCustomer.ValueMember   = "CustomerID";
         cmbCustomer.Text          = "All";
         /*****************      Bind the Customer Combo*******************/
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(), "BindCustomerComboBox", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
    public int DeleteCustomer(clsCustomerMaster obj)
    {
        SqlConnection con = new SqlConnection(constring);
        SqlCommand    cmd = new SqlCommand("spDeleteCustomer", con);

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@CustomerID", obj.CustomerID);
        cmd.Parameters.AddWithValue("@UserID", obj.UserID);
        con.Open();
        int count = cmd.ExecuteNonQuery();

        con.Close();
        return(count);
    }
Exemplo n.º 3
0
 public void BindDataGrid()
 {
     try
     {
         clsCustomerMaster objLoad = new clsCustomerMaster();
         objLoad.Mode      = "SELECTALL";
         objLoad.CompanyID = cId;
         dgvCustomerMaster.AutoGenerateColumns = false;
         var ds = objLoad.GetAllCustomer();
         dgvCustomerMaster.DataSource = ds.Tables[0];
         lblRecordCount.Text          = ds.Tables[0].Rows.Count.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(), "BindDataGrid", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
    public int InsertUpdateCustomer(clsCustomerMaster obj)
    {
        SqlConnection con = new SqlConnection(constring);
        SqlCommand    cmd = new SqlCommand("spInsertUpdateCustomer", con);

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("CustomerID", obj.CustomerID);
        cmd.Parameters.AddWithValue("Name", obj.Name);
        cmd.Parameters.AddWithValue("MobileNo", obj.MobileNo);
        cmd.Parameters.AddWithValue("Gender", obj.Gender);
        cmd.Parameters.AddWithValue("EmailID", obj.EmailID);
        cmd.Parameters.AddWithValue("UserID", obj.UserID);
        con.Open();
        obj.CustomerID = Convert.ToInt32(cmd.ExecuteScalar());
        con.Close();
        return(obj.CustomerID);
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        lblmsg.Text = string.Empty;
        GridViewRow gvr = ((Button)sender).Parent.Parent as GridViewRow;

        obj = new clsCustomerMaster();
        DataTable dt = obj.SelectCustomer(Convert.ToInt32(gvCustomer.DataKeys[gvr.RowIndex]["CustomerID"].ToString()));

        if (dt.Rows.Count > 0)
        {
            (gvCustomer.FooterRow.FindControl("hdfCustomerIDft") as HiddenField).Value = dt.Rows[0]["CustomerID"].ToString();
            (gvCustomer.FooterRow.FindControl("txtName") as TextBox).Text     = dt.Rows[0]["Name"].ToString();
            (gvCustomer.FooterRow.FindControl("txtMobileNo") as TextBox).Text = dt.Rows[0]["MobileNo"].ToString();
            (gvCustomer.FooterRow.FindControl("txtEmailID") as TextBox).Text  = dt.Rows[0]["EmailID"].ToString();
            (gvCustomer.FooterRow.FindControl("rdbGender") as RadioButtonList).Items.FindByValue(dt.Rows[0]["Gender"].ToString()).Selected = true;
        }
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        lblmsg.Text = string.Empty;
        GridViewRow gvr = ((Button)sender).Parent.Parent as GridViewRow;

        obj            = new clsCustomerMaster();
        obj.CustomerID = Convert.ToInt32(gvCustomer.DataKeys[gvr.RowIndex]["CustomerID"].ToString());
        obj.UserID     = Convert.ToInt32(Session["UserID"]);
        if (obj.DeleteCustomer(obj) > 0)
        {
            lblmsg.Text = "Record Deleted Successfully";
            this.BindGridView();
        }
        else
        {
            lblmsg.Text = "Opertation Failed!!!";
        }
    }
Exemplo n.º 7
0
 public void SearchBindDataGrid()
 {
     try
     {
         dgvCustomerMaster.DataSource = null;
         clsCustomerMaster objLoad = new clsCustomerMaster();
         objLoad.Mode                          = "SELECTALL";
         objLoad.CompanyID                     = cId;
         objLoad.CustomerName                  = txtSearchCustomer.Text;
         objLoad.CustomerContactNo             = txtSearchContactPerson.Text;
         objLoad.CustomerAddress               = txtSearchAddress.Text;
         dgvCustomerMaster.AutoGenerateColumns = false;
         var ds = objLoad.GetSearchCustomer();
         dgvCustomerMaster.DataSource = ds.Tables[0];
         lblRecordCount.Text          = ds.Tables[0].Rows.Count.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(), "SearchBindDataGrid", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        lblmsg.Text = string.Empty;
        obj         = new clsCustomerMaster();
        GridViewRow gvr = ((Button)sender).Parent.Parent as GridViewRow;
        string      hdf = (gvr.FindControl("hdfCustomerIDft") as HiddenField).Value;

        obj.CustomerID = (hdf == string.Empty || hdf == "0") ? 0 : Convert.ToInt32(hdf);
        obj.Name       = (gvr.FindControl("txtName") as TextBox).Text.Trim();
        obj.MobileNo   = (gvr.FindControl("txtMobileNo") as TextBox).Text.Trim();
        obj.EmailID    = (gvr.FindControl("txtEmailID") as TextBox).Text.Trim();
        obj.Gender     = (gvr.FindControl("rdbGender") as RadioButtonList).SelectedItem.Text;
        obj.UserID     = Convert.ToInt32(Session["UserID"]);
        if (obj.InsertUpdateCustomer(obj) > 0)
        {
            lblmsg.Text = "Record " + ((hdf == string.Empty || hdf == "0") ? "Inserted" : "Updated") + " Successfully";
            Clear(gvr);
            this.BindGridView();
        }
        else
        {
            lblmsg.Text = "Opertation Failed!!!";
        }
    }
Exemplo n.º 9
0
        public void SaveFormData(String mode)
        {
            try
            {
                clsCustomerMaster objSave = new clsCustomerMaster();
                objSave.CustomerID            = Convert.ToInt32(txtKey.Text);
                objSave.CustomerName          = txtCustomerName.Text;
                objSave.CustomerAddress       = txtCustomerAddress.Text;
                objSave.CustomerContactPerson = txtContactPerson.Text;
                objSave.CustomerContactNo     = txtContactNo.Text;
                objSave.CompanyID             = cId;
                objSave.CustomerPanNo         = txtCustomerPanNo.Text;
                String cstDate = dtpCstTinDate.Value.ToString("dd/MM/yyyy");
                if (DateTime.Now.ToString("dd/MM/yyyy") != cstDate)
                {
                    objSave.CustomerCSTDate = clsCommoan.GetDateInddMMYYYY(dtpCstTinDate.Value.ToString());
                }
                String gstDate = dtpGstTinDate.Value.ToString("dd/MM/yyyy");
                if (DateTime.Now.ToString("dd/MM/yyyy") != gstDate)
                {
                    objSave.CustomerGSTDate = clsCommoan.GetDateInddMMYYYY(dtpGstTinDate.Value.ToString());
                }
                objSave.Mode = mode.ToUpper();
                if (mode.ToUpper().Equals("DELETE"))
                {
                    var confirmation = MessageBox.Show("Are You Sure You Want to Delete " + " " + txtCustomerName.Text, "Customer Master Alert", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (confirmation.ToString().Equals("Yes"))
                    {
                        objSave.AddUpdateDelete();
                        BindDataGrid();
                        ResetFormControl();
                    }
                }
                else
                {
                    String msg = objSave.Validation();



                    //if (txtcstTinNo.Text.Length != 11 && txtcstTinNo.Text.Length>0)
                    //{
                    //    if (msg.Length.Equals(0))
                    //    {
                    //        msg = "Please Enter the 11 Digit  Cst Tin No: ";
                    //    }
                    //    else
                    //    {
                    //        msg = msg + "\n Please Enter the 11 Digit Valid Cst Tin No: ";
                    //    }
                    //}
                    //if (txtGstTinNo.Text.Length < 11 && txtGstTinNo.Text.Length > 0)
                    //{
                    //    if (txtGstTinNo.Text.Length!=11)
                    //    {
                    //        if (msg.Length.Equals(0))
                    //        {
                    //            msg = "Please Enter the 11 Digit Valid Gst Tin No: ";
                    //        }
                    //        else
                    //        {
                    //            msg = msg +  "\n Please Enter the 11 Digit Valid Gst Tin No: ";
                    //        }
                    //    }
                    //}
                    if (msg.Length > 0)
                    {
                        MessageBox.Show(msg, "Customer Master Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        objSave.CustomerCSTNo = txtcstTinNo.Text;
                        if (txtGstTinNo.Text.Length > 0)
                        {
                            objSave.CustomerGSTNo = txtGstTinNo.Text;
                        }
                        objSave.AddUpdateDelete();
                        MessageBox.Show(txtCustomerName.Text + " " + mode + " Success Fully", "Customer Master Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        BindDataGrid();
                        ResetFormControl();
                        if (pageAction.Equals("Yes"))
                        {
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "SaveFormData", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void BindGridView()
 {
     obj = new clsCustomerMaster();
     gvCustomer.DataSource = obj.SelectCustomer(0);
     gvCustomer.DataBind();
 }
Exemplo n.º 11
0
        public string SaveCustomer(clsCustomerMaster CustomerData, clsCustomerContactMaster[] ContactData)
        {
            string msg = "";


            /* Next Doc NO */
            int    nextDocNo   = 0;
            int    Link12      = 0;
            string FormattedNo = "";

            // LOGIN COMPANY LINK(ID)
            clsCustomerMaster obj = CustomerData;

            obj.CompanyLink = HttpContext.Current.Request.Cookies["CompanyLink"].Value.ToString();

            // CHECK DUPLICATE
            DataTable objdup = clsMethods.GetDuplicateCustomer(obj.Username, obj.CompanyLink);

            if (objdup.Rows.Count > 0)
            {
                if (obj.Link.ToString() == "0")
                {
                    return("Customer is already in use, Please Enter another Name.");
                }
                else
                if (objdup.Rows.Count >= 2)
                {
                    return("Customer is already in use, Please Enter another Name.");
                }
                else
                if (objdup.Rows[0]["Link"].ToString() != obj.Link.ToString())
                {
                    return("Customer is already in use, Please Enter another Name.");
                }
            }

            obj.IsDeactivate = false;

            // LINK 0 THEN INSERT ELSE UPDATE RECORD
            if (obj.Link.ToString() == "0")
            {
                DataTable dtNext = clsMethods.GetDocNo("QA");
                if (dtNext.Rows.Count > 0)
                {
                    // GET NEXT CUSTOMER NUMBER , NUMBER WILL BE LIKE THIS : QA00001
                    nextDocNo   = Convert.ToInt32(dtNext.Rows[0]["Next_Doc_No"].ToString());
                    Link12      = Convert.ToInt32(dtNext.Rows[0]["Link"].ToString());
                    FormattedNo = clsMethods.FormatDocumentNo("QA", Convert.ToDecimal(nextDocNo));
                }
                // CREATED BY , CREATED HOST NAME, DATE OF CREATION FOR ALL THE RECORD WHICH IS INSERT FOR ALL TABLE
                obj.CustomerNo      = FormattedNo;
                obj.CreatedBy       = Convert.ToInt32(HttpContext.Current.Request.Cookies["UserId"].Value);
                obj.CreatedHostName = HttpContext.Current.Request.UserHostName;
                obj.DateOfCreation  = DateTime.Now;
            }
            else
            {
                // MODIFIED BY , MODIFIED HOST , MODIFIED DATE WHEN RECORD UPDATE.
                obj.LastModifiedBy   = Convert.ToInt32(HttpContext.Current.Request.Cookies["UserId"].Value);
                obj.LastModifiedHost = HttpContext.Current.Request.UserHostName;
                obj.LastModifiedDate = DateTime.Now;
            }
            // THIS IS THE FUNCTION IN BAL PROJECT WHERE INSERT,UPDATE OR DELETE QUERY CREATE BASED ON THE OBJECT WHICH HAS DEFINE IN CLASS FILE.
            clsIFrameWork.SetIndependentTable(obj);

            // CREATE CONTACT
            for (int i = 0; i < ContactData.Length; i++)
            {
                clsCustomerContactMaster objM = ContactData[i];
                objM.CustomerNo  = obj.CustomerNo;
                objM.CompanyLink = HttpContext.Current.Request.Cookies["CompanyLink"].Value.ToString();

                // LINK 0 THEN INSERT ELSE UPDATE RECORD
                if (objM.Link.ToString() == "0")
                {
                    // CREATED BY , CREATED HOST NAME, DATE OF CREATION FOR ALL THE RECORD WHICH IS INSERT FOR ALL TABLE
                    objM.CreatedBy       = Convert.ToInt32(HttpContext.Current.Request.Cookies["UserId"].Value);
                    objM.CreatedHostName = HttpContext.Current.Request.UserHostName;
                    objM.DateOfCreation  = DateTime.Now;
                }
                else
                {
                    // MODIFIED BY , MODIFIED HOST , MODIFIED DATE WHEN RECORD UPDATE.
                    objM.LastModifiedBy   = Convert.ToInt32(HttpContext.Current.Request.Cookies["UserId"].Value);
                    objM.LastModifiedHost = HttpContext.Current.Request.UserHostName;
                    objM.LastModifiedDate = DateTime.Now;
                }
                // THIS IS THE FUNCTION IN BAL PROJECT WHERE INSERT,UPDATE OR DELETE QUERY CREATE BASED ON THE OBJECT WHICH HAS DEFINE IN CLASS FILE.
                clsIFrameWork.SetIndependentTable(objM);
            }

            bool issucc = false;

            try
            {
                // TRACACTION IS EXECUTE , SO ABOVE CREATED ALL QUERY WILL EXECUTE AT SAME TIME.
                issucc = clsIFrameWork.FireTransaction();
            }
            catch (Exception ex)
            {
                // ERROR LOG
                FileStream fs = new FileStream(ServerLogFile, FileMode.Append, FileAccess.Write, FileShare.Write);
                fs.Close();
                StreamWriter sw = new StreamWriter(ServerLogFile, true, Encoding.ASCII);
                sw.WriteLine(ex.ToString() + System.DateTime.Now.ToString());
                sw.Close();
                msg = ex.Message;
            }
            if (issucc)
            {
                return("Record Saved Successfully.");
            }
            else
            {
                return(msg);
            }
        }