Example #1
0
 public int deleteRecord(EntCustomerDetails objent)
 {
     SqlConnection con = new SqlConnection(ConnectionString);
     con.Open();
     SqlCommand cmd = new SqlCommand("Usp_DeleteCustomer", con);
     cmd.CommandType = CommandType.StoredProcedure;
     try
     {
         cmd.Parameters.AddWithValue("@CustomerId",objent.CustomerId);
        int result = cmd.ExecuteNonQuery();
        // string strMessage = "Data Saved";
         con.Close();
         return result;
     }
     catch (Exception ex)
     {
         throw ex;
      //  MessageBox.Show(ex.Message.ToString());
     }
     finally
     {
         cmd.Dispose();
         con.Close();
         con.Dispose();
     }
 }
Example #2
0
 public CustomerDetails()
 {
     InitializeComponent();
     EntCustomerDetails objentcustomerDetails = new EntCustomerDetails();
     getCustomerId();
     FillCustomerNames();
     bindGrid();
 }
Example #3
0
        public string UpdateCustomer(EntCustomerDetails objentcustomerDetails)
        {
            try
            {
                DlCustomerDetails objDLCustomerDetail = new DlCustomerDetails();
                return objDLCustomerDetail.UpdateCustomer(objentcustomerDetails);
            }
            catch (Exception ex)
            {

                throw ex;
               //MessageBox.Show(ex.Message.ToString());

            }

            finally
            {

                // objDLCustomerDetail = null;

            }
        }
Example #4
0
        public string SaveCustomer(EntCustomerDetails objentcustomerDetails)
        {
            string msg = "Saved";
            try
            {
                DlCustomerDetails objDLCustomerDetail = new DlCustomerDetails();
                return objDLCustomerDetail.SaveCustomer(objentcustomerDetails);
            }
            catch (Exception ex)
            {

               //MessageBox.Show(ex.Message.ToString());

            }

            finally
            {

                // objDLCustomerDetail = null;

            }
            return msg;
        }
Example #5
0
        private void searchCustomer()
        {
            try
            {
                DataTable dt = new DataTable();
                BLCustomerDetails objBL = new BLCustomerDetails();
                EntCustomerDetails objent = new EntCustomerDetails();

                    objent.CustomerId = Convert.ToInt32(cbCustomerName.SelectedValue);
                    objent.Name = cbCustomerName.Text;
                    dt = objBL.searchCustomer(objent);
                    if (dt.Rows.Count > 0)
                    {
                        dataGridView1.DataSource = dt;

                        dataGridView1.Columns["CustomerId"].Visible = false;
                        //dataGridView1.Columns[1].HeaderCell.Value = "Sr.No";

                        dataGridView1.Refresh();
                        dataGridView1.Show();
                    }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Example #6
0
        private void SaveCutomerDetails()
        {
            if (Validate())
            {
                if (btnSave.Text == "Save")
                {
                    string result = "";
                    string Output = string.Empty;
                    EntCustomerDetails objentcustomerDetails = new EntCustomerDetails();
                    objentcustomerDetails.CustomerId = Convert.ToInt32(txtcustomerId.Text);
                    objentcustomerDetails.Name = txtcustomername.Text;
                    objentcustomerDetails.MobileNumber = txtmobileNo.Text;
                    objentcustomerDetails.AlternateMobileNo = txtAlternatemobileNo.Text;
                    objentcustomerDetails.Address = txtAddress.Text;
                    objentcustomerDetails.Reference = txtreference.Text;
                    objentcustomerDetails.Nominee = txtnominee.Text;
                    objentcustomerDetails.CreatedDate = DateTime.Now;
                    objentcustomerDetails.CreatedDate = Convert.ToDateTime(txtdate.Text);
                    if (cknotification.Checked == true)
                    {
                        result = "yes";
                    }
                    else
                    {
                        result = "No";
                    }
                    objentcustomerDetails.RequiredSMSnotification = result;
                    objentcustomerDetails.BankName = txtbankName.Text;
                    objentcustomerDetails.BankAccountNo = txtbankAccount.Text;
                    BLCustomerDetails objblcustomerdetails = new BLCustomerDetails();
                    Output = objblcustomerdetails.SaveCustomer(objentcustomerDetails);
                    if (Output == "This record already exists!")
                    {
                        MessageBox.Show(Output);
                    }
                    else
                    {
                        MessageBox.Show("Customer Added Sucessfully..");
                    }
                    // ClearFields();
                    ClearFields();
                    getCustomerId();
                    bindGrid();
                    FillCustomerNames();
                }
                else
                {
                    string result = "";
                    string Output = string.Empty;
                    EntCustomerDetails objentcustomerDetails = new EntCustomerDetails();
                    objentcustomerDetails.CustomerId = Convert.ToInt32(txtcustomerId.Text);
                    objentcustomerDetails.Name = txtcustomername.Text;
                    objentcustomerDetails.MobileNumber = txtmobileNo.Text;
                    objentcustomerDetails.AlternateMobileNo = txtAlternatemobileNo.Text;
                    objentcustomerDetails.Address = txtAddress.Text;
                    objentcustomerDetails.Reference = txtreference.Text;
                    objentcustomerDetails.Nominee = txtnominee.Text;
                    //objentcustomerDetails.CreatedDate = DateTime.Now;
                    objentcustomerDetails.CreatedDate = Convert.ToDateTime(txtdate.Text);
                    if (cknotification.Checked == true)
                    {
                        result = "yes";
                    }
                    else
                    {
                        result = "No";
                    }
                    objentcustomerDetails.RequiredSMSnotification = result;
                    objentcustomerDetails.BankName = txtbankName.Text;
                    objentcustomerDetails.BankAccountNo = txtbankAccount.Text;
                    BLCustomerDetails objblcustomerdetails = new BLCustomerDetails();
                    Output = objblcustomerdetails.UpdateCustomer(objentcustomerDetails);
                    if (Output == "This record already exists!")
                    {
                        MessageBox.Show(Output);
                    }
                    else
                    {
                        MessageBox.Show("Customer Updated Sucessfully!!! ");

                    }
                    btnSave.Text = "Save";
                    ClearFields();
                    getCustomerId();
                    bindGrid();
                    FillCustomerNames();
                }
            }
        }
Example #7
0
        public string UpdateCustomer(EntCustomerDetails objentcustomerDetails)
        {
            SqlConnection con = new SqlConnection(ConnectionString);
            con.Open();
            // SqlCommand cmd = new SqlCommand("Usp_SaveCustomerDetails", con); temp comment
            SqlCommand cmd = new SqlCommand("Usp_SaveCustomerDetails", con);
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                cmd.Parameters.AddWithValue("@CustomerId", objentcustomerDetails.CustomerId);
                cmd.Parameters.AddWithValue("@CustomerName", objentcustomerDetails.Name);
                cmd.Parameters.AddWithValue("@MobileNo", objentcustomerDetails.MobileNumber);
                cmd.Parameters.AddWithValue("@AlterNameMobileNo", objentcustomerDetails.AlternateMobileNo);
                cmd.Parameters.AddWithValue("@Address", objentcustomerDetails.Address);
                cmd.Parameters.AddWithValue("@Reference", objentcustomerDetails.Reference);
                cmd.Parameters.AddWithValue("@Nominee", objentcustomerDetails.Nominee);
                cmd.Parameters.AddWithValue("@SMSRequire", objentcustomerDetails.RequiredSMSnotification);
                //cmd.Parameters.AddWithValue("@Identityproof", objentcustomerDetails.IdentityProof);
                cmd.Parameters.AddWithValue("@BankName", objentcustomerDetails.BankName);
                cmd.Parameters.AddWithValue("@AccountNo", objentcustomerDetails.BankAccountNo);
                //cmd.Parameters.AddWithValue("@CreditCardNo", objentcustomerDetails.CreditcardNo);
                DateTime da = DateTime.Now;
                cmd.Parameters.AddWithValue("@Date", da);

                string strMessage =Convert.ToString(cmd.ExecuteScalar());
                con.Close();
                return strMessage;
            }
            catch (Exception ex)
            {
                throw ex;
              // MessageBox.Show(ex.Message.ToString());
            }
            finally
            {
                cmd.Dispose();
                con.Close();
                con.Dispose();
            }
        }
Example #8
0
 public DataTable SearchCustomer(EntCustomerDetails objent)
 {
     string msg = "Saved";
     SqlConnection con = new SqlConnection(ConnectionString);
     con.Open();
     SqlCommand cmd = new SqlCommand("Usp_SearchCustomer", con);
     cmd.CommandType = CommandType.StoredProcedure;
     try
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@CustomerId", objent.CustomerId);
         cmd.Parameters.AddWithValue("@CustomerName", objent.Name);
         SqlDataAdapter sqlDa = new SqlDataAdapter(cmd);
         DataTable dt = new DataTable();
         sqlDa.Fill(dt);
         return dt;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         cmd.Dispose();
         con.Close();
         con.Dispose();
     }
 }
Example #9
0
 public DataTable searchCustomer(EntCustomerDetails objent)
 {
     DlCustomerDetails objDAL = new DlCustomerDetails();
     return objDAL.SearchCustomer(objent);
 }