protected void LoadCustomerPurchaseList() { Business.Customer.Customer objCustomerMaster = new Business.Customer.Customer(); Entity.Customer.Customer customerMaster = new Entity.Customer.Customer(); gvMachineList.DataSource = objCustomerMaster.CustomerPurchase_GetByCustomerId(CustomerMasterId); gvMachineList.DataBind(); }
private void Customer_Customer_GetByAssignEngineerId() { Business.Customer.Customer objCustomer = new Business.Customer.Customer(); Entity.Customer.Customer customer = new Entity.Customer.Customer(); if (HttpContext.Current.User.IsInRole(Entity.HR.Utility.CUSTOMER_LIST_SHOW_ALL)) { customer.AssignEngineer = 0; } else { customer.AssignEngineer = int.Parse(HttpContext.Current.User.Identity.Name); } customer.CustomerName = txtName.Text.Trim(); customer.PageIndex = gvCustomerMaster.PageIndex; customer.PageSize = gvCustomerMaster.PageSize; DataSet ds = objCustomer.Customer_CustomerMaster_GetByAssignEngineerIdWithPaging(customer); if (ds.Tables.Count > 0) { gvCustomerMaster.DataSource = ds.Tables[0]; gvCustomerMaster.VirtualItemCount = (ds.Tables[1].Rows.Count > 0) ? Convert.ToInt32(ds.Tables[1].Rows[0]["TotalCount"].ToString()) : 10; gvCustomerMaster.DataBind(); } else { gvCustomerMaster.DataSource = null; gvCustomerMaster.DataBind(); } }
protected void LoadCustomerPurchaseList() { Business.Customer.Customer objCustomerMaster = new Business.Customer.Customer(); Entity.Customer.Customer customerMaster = new Entity.Customer.Customer(); gvPurchase.DataSource = objCustomerMaster.CustomerPurchase_GetByCustomerId(int.Parse(HttpContext.Current.User.Identity.Name.Split('|')[(int)Constants.Customer.ID])); gvPurchase.DataBind(); }
public static DataTable FetchCustomerDetailsById(Entity.Customer.Customer ObjElCustomer) { using (DataTable dt = new DataTable()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_Customer_Customer_GetById"; cmd.Parameters.AddWithValue("@CustomerMasterId", ObjElCustomer.CustomerMasterId); if (con.State == ConnectionState.Closed) { con.Open(); } using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt); } con.Close(); } } return(dt); } }
public static long Save(Entity.Customer.Customer customer) { int rowsAffacted = 0; using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandText = "usp_Customer_Customer_Save"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CustomerMasterId", customer.CustomerMasterId); cmd.Parameters.AddWithValue("@CustomerName", customer.CustomerName); cmd.Parameters.AddWithValue("@CustomerType", customer.CustomerType); cmd.Parameters.AddWithValue("@ReferenceName", customer.ReferenceName); cmd.Parameters.AddWithValue("@MobileNo", customer.MobileNo); cmd.Parameters.AddWithValue("@PhoneNo", customer.PhoneNo); cmd.Parameters.AddWithValue("@EmailId", customer.EmailId); cmd.Parameters.AddWithValue("@pAddress", customer.PAddress); cmd.Parameters.AddWithValue("@pStreet", customer.PStreet); cmd.Parameters.AddWithValue("@Pin", customer.Pin); cmd.Parameters.AddWithValue("@UserId", customer.UserId); cmd.Parameters.AddWithValue("@CompanyMasterId_FK", customer.CompanyMasterId_FK); if (con.State == ConnectionState.Closed) { con.Open(); } rowsAffacted = cmd.ExecuteNonQuery(); con.Close(); } } return(rowsAffacted); }
protected void btnFind_Click(object sender, EventArgs e) { try { hdnOpenForm.Value = "true"; Business.Customer.Customer objCustomer = new Business.Customer.Customer(); Entity.Customer.Customer customer = new Entity.Customer.Customer(); customer.CustomerMasterId = GetCustomerIdByName(txtCustomerName.Text); DataTable dt = objCustomer.FetchCustomerDetailsById(customer); if (dt.Rows.Count > 0) { txtName.Text = dt.Rows[0]["CustomerName"].ToString(); //ddlCustomerType.SelectedValue = dt.Rows[0]["CustomerType"].ToString(); txtOfficePhone.Text = dt.Rows[0]["PhoneNo"].ToString(); } } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }
public static DataSet Customer_GetAll(Entity.Customer.Customer customer) { using (DataSet ds = new DataSet()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_Customer_Customer_GetAll"; cmd.Parameters.AddWithValue("@CompanyId", customer.CompanyMasterId_FK); cmd.Parameters.AddWithValue("@CustomerName", customer.CustomerName); cmd.Parameters.AddWithValue("@EmailId", customer.EmailId); cmd.Parameters.AddWithValue("@MobileNo", customer.MobileNo); cmd.Parameters.AddWithValue("@CustomerCode", customer.CustomerCode); cmd.InsertPaging(customer, customer.CustomerMasterId); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } con.Close(); } } return(ds); } }
public static string CustomerPurchase_Save(Entity.Customer.Customer customer) { string retValue = string.Empty; using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandText = "usp_Customer_CustomerPurchase_Save"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CustomerPurchaseId", customer.CustomerPurchaseId); cmd.Parameters.AddWithValue("@CustomerMasterId_FK", customer.CustomerMasterId); cmd.Parameters.AddWithValue("@ProductMasterId_FK", customer.Productid); cmd.Parameters.AddWithValue("@ProductSerialNo", customer.SerialNo); cmd.Parameters.Add("@MachineId", SqlDbType.VarChar, 50, customer.MachineId); cmd.Parameters["@MachineId"].Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@UserId", customer.UserId); cmd.Parameters.AddWithValue("@CompanyMasterId_FK", customer.CompanyMasterId_FK); cmd.Parameters.AddWithValue("@ContactPerson", customer.ContactPerson); cmd.Parameters.AddWithValue("@Address", customer.Address); cmd.Parameters.AddWithValue("@MobileNo", customer.MobileNo); if (customer.InstallationDate == DateTime.MinValue) { cmd.Parameters.AddWithValue("@InstallationDate", DBNull.Value); } else { cmd.Parameters.AddWithValue("@InstallationDate", customer.InstallationDate); } if (customer.AssignEngineer == 0) { cmd.Parameters.AddWithValue("@AssignEngineer", DBNull.Value); } else { cmd.Parameters.AddWithValue("@AssignEngineer", customer.AssignEngineer); } if (string.IsNullOrEmpty(customer.Stamp)) { cmd.Parameters.AddWithValue("@Stamp", DBNull.Value); } else { cmd.Parameters.AddWithValue("@Stamp", customer.Stamp); } if (con.State == ConnectionState.Closed) { con.Open(); } cmd.ExecuteNonQuery(); retValue = cmd.Parameters["@MachineId"].Value.ToString(); con.Close(); } } return(retValue); }
protected void gvCustomerMaster_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "E") { CustomerId = Convert.ToInt64(e.CommandArgument.ToString()); FetchCustomerDetailsById(CustomerId); } else if (e.CommandName == "D") { CustomerId = Convert.ToInt64(e.CommandArgument.ToString()); Business.Customer.Customer ObjBelCustomer = new Business.Customer.Customer(); Entity.Customer.Customer ObjElCustomer = new Entity.Customer.Customer(); ObjElCustomer.CustomerMasterId = CustomerId; int i = 0; i = ObjBelCustomer.DeleteCustomer(ObjElCustomer); if (i > 0) { GlobalCache.RemoveAll(); CleartextBoxes(this); ScriptManager.RegisterStartupScript(this, this.GetType(), "mmsg", "alert('Data Delete Succesfully....');", true); CustomerId = 0; GetAllCustomer(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "mmsg", "alert('Data Can not Delete!!!....');", true); } } else if (e.CommandName == "Address") { CustomerId = Convert.ToInt64(e.CommandArgument.ToString()); GetAllAddress(Convert.ToInt64(e.CommandArgument.ToString())); TabContainer2.ActiveTab = AddressList; ModalPopupExtender2.Show(); } else if (e.CommandName == "Contact") { CustomerId = Convert.ToInt64(e.CommandArgument.ToString()); GetAllACustomerContactDetails(Convert.ToInt64(e.CommandArgument.ToString())); TabContainer1.ActiveTab = ContactDetails; ModalPopupExtender1.Show(); } } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }
public static DataSet Customer_CustomerPurchase_GetAll(Entity.Customer.Customer customer) { using (DataSet ds = new DataSet()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandText = "usp_Customer_CustomerPurchase_GetAll"; cmd.CommandType = CommandType.StoredProcedure; if (string.IsNullOrEmpty(customer.CustomerName)) { cmd.Parameters.AddWithValue("@CustomerName", DBNull.Value); } else { cmd.Parameters.AddWithValue("@CustomerName", customer.CustomerName); } if (string.IsNullOrEmpty(customer.SerialNo)) { cmd.Parameters.AddWithValue("@ProductSerialNumber", DBNull.Value); } else { cmd.Parameters.AddWithValue("@ProductSerialNumber", customer.SerialNo); } if (customer.AssignEngineer == 0) { cmd.Parameters.AddWithValue("@AssignedEngineerId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@AssignedEngineerId", customer.AssignEngineer); } cmd.InsertPaging(customer, customer.CustomerMasterId); if (con.State == ConnectionState.Closed) { con.Open(); } using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } con.Close(); } } return(ds); } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { Business.Customer.Customer objCustomer = new Business.Customer.Customer(); Entity.Customer.Customer customer = new Entity.Customer.Customer(); customer.CompanyMasterId_FK = 1; customer.CustomerMasterId = CustomerId; customer.CustomerName = txtCustomerName.Text; customer.CustomerType = Convert.ToInt16(ddlCustomerType.SelectedValue); customer.EmailId = txtEmailId.Text; customer.MobileNo = txtMobileNo.Text; customer.PAddress = txtpAddress.Text; customer.PhoneNo = txtPhoneNo.Text; customer.Pin = txtPin.Text; customer.PStreet = txtpStreet.Text; customer.ReferenceName = txtrefferenceName.Text; customer.UserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name); long i = objCustomer.Save(customer); if (i > 0) { GlobalCache.RemoveAll(); CleartextBoxes(this); GetAllCustomer(); CustomerId = 0; Message.IsSuccess = true; Message.Text = "Customer information saved successfully..."; } else { Message.IsSuccess = false; Message.Text = "Can not save!!!"; } Message.Show = true; } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }
public static Entity.Customer.Customer CustomerPurchase_GetByCustomerPurchaseId(int customerpurchaseid) { Entity.Customer.Customer customer = new Entity.Customer.Customer(); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_Customer_CustomerPurchase_GetByCustomerPurchaseId"; cmd.Parameters.AddWithValue("@CustomerPurchaseId", customerpurchaseid); if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { customer.CustomerPurchaseId = customerpurchaseid; customer.CustomerMasterId = (dr["CustomerMasterId_FK"] == DBNull.Value) ? 0 : int.Parse(dr["CustomerMasterId_FK"].ToString()); customer.BrandId = (dr["BrandId_FK"] == DBNull.Value) ? 0 : int.Parse(dr["BrandId_FK"].ToString()); customer.Productid = (dr["ProductMasterId_FK"] == DBNull.Value) ? 0 : int.Parse(dr["ProductMasterId_FK"].ToString()); customer.SerialNo = (dr["ProductSerialNo"] == DBNull.Value) ? string.Empty : dr["ProductSerialNo"].ToString(); customer.MachineId = (dr["MachineId"] == DBNull.Value) ? string.Empty : dr["MachineId"].ToString(); customer.ContactPerson = (dr["ContactPerson"] == DBNull.Value) ? string.Empty : dr["ContactPerson"].ToString(); customer.Address = (dr["Address"] == DBNull.Value) ? string.Empty : dr["Address"].ToString(); customer.PhoneNo = (dr["Phone"] == DBNull.Value) ? string.Empty : dr["Phone"].ToString(); customer.MobileNo = (dr["MobileNo"] == DBNull.Value) ? string.Empty : dr["MobileNo"].ToString(); customer.AssignEngineer = (dr["AssignEngineer"] == DBNull.Value) ? 0 : int.Parse(dr["AssignEngineer"].ToString()); customer.InstallationDate = (dr["InstallationDate"] == DBNull.Value) ? DateTime.MinValue : DateTime.Parse(dr["InstallationDate"].ToString()); customer.A3BWMeterReading = (dr["A3BWLastMeterReading"] == DBNull.Value) ? 0 : Int64.Parse(dr["A3BWLastMeterReading"].ToString()); customer.A3CLMeterReading = (dr["A3CLLastMeterReading"] == DBNull.Value) ? 0 : Int64.Parse(dr["A3CLLastMeterReading"].ToString()); customer.A4BWMeterReading = (dr["A4BWLastMeterReading"] == DBNull.Value) ? 0 : Int64.Parse(dr["A4BWLastMeterReading"].ToString()); customer.A4CLMeterReading = (dr["A4CLLastMeterReading"] == DBNull.Value) ? 0 : Int64.Parse(dr["A4CLLastMeterReading"].ToString()); } } con.Close(); } } return(customer); }
private void FetchCustomerDetailsById(long Id) { Business.Customer.Customer objCustomer = new Business.Customer.Customer(); Entity.Customer.Customer customer = new Entity.Customer.Customer(); customer.CustomerMasterId = Id; DataTable dt = objCustomer.FetchCustomerDetailsById(customer); if (dt.Rows.Count > 0) { txtCustomerName.Text = dt.Rows[0]["CustomerName"].ToString(); ddlCustomerType.SelectedValue = dt.Rows[0]["CustomerType"].ToString(); txtEmailId.Text = dt.Rows[0]["EmailId"].ToString(); txtMobileNo.Text = dt.Rows[0]["MobileNo"].ToString(); txtpAddress.Text = dt.Rows[0]["pAddress"].ToString(); txtPhoneNo.Text = dt.Rows[0]["PhoneNo"].ToString(); txtPin.Text = dt.Rows[0]["Pin"].ToString(); txtpStreet.Text = dt.Rows[0]["pStreet"].ToString(); txtrefferenceName.Text = dt.Rows[0]["ReferenceName"].ToString(); } }
private void LoadCustomerPurchase() { Business.Customer.Customer objCustomer = new Business.Customer.Customer(); Entity.Customer.Customer customer = new Entity.Customer.Customer() { CustomerName = txtCustomerName.Text.Trim(), SerialNo = txtSerialNo.Text.Trim(), AssignEngineer = Convert.ToInt32(ddlAssignedEngineer.SelectedValue), PageIndex = gvCustomerPurchase.PageIndex, PageSize = gvCustomerPurchase.PageSize, }; DataSet dsPurchase = objCustomer.Customer_CustomerPurchase_GetAll(customer); if (dsPurchase.Tables.Count > 1) { gvCustomerPurchase.DataSource = dsPurchase.Tables[0]; gvCustomerPurchase.VirtualItemCount = (dsPurchase.Tables[1].Rows.Count > 0) ? Convert.ToInt32(dsPurchase.Tables[1].Rows[0]["TotalCount"].ToString()) : 10; gvCustomerPurchase.DataBind(); } }
public static int DeleteCustomer(Entity.Customer.Customer ObjElCustomer) { int rowsAffacted = 0; using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandText = "usp_Customer_Customer_Delete"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CustomerMasterId", ObjElCustomer.CustomerMasterId); if (con.State == ConnectionState.Closed) { con.Open(); } rowsAffacted = cmd.ExecuteNonQuery(); con.Close(); } } return(rowsAffacted); }
protected void gvCustomerMaster_RowCommand(object sender, GridViewCommandEventArgs e) { try { Business.Customer.Customer objCustomer = new Business.Customer.Customer(); Entity.Customer.Customer customer = new Entity.Customer.Customer(); if (e.CommandName == "PurchaseDetails") { CustomerMasterId = int.Parse(e.CommandArgument.ToString()); customer.CustomerMasterId = CustomerMasterId; DataTable dr = objCustomer.FetchCustomerDetailsById(customer); popupHeader1.InnerHtml = (objCustomer.FetchCustomerDetailsById(customer) == null) ? "" : dr.Rows[0]["CustomerName"].ToString(); LoadCustomerPurchaseList(); ClearControl(); ModalPopupExtender1.Show(); } else if (e.CommandName == "ContractDetails") { CustomerMasterId = int.Parse(e.CommandArgument.ToString()); customer.CustomerMasterId = CustomerMasterId; DataTable dr = objCustomer.FetchCustomerDetailsById(customer); popupHeader2.InnerHtml = (objCustomer.FetchCustomerDetailsById(customer) == null) ? "" : dr.Rows[0]["CustomerName"].ToString(); LoadCustomerPurchaseListForContract(); LoadContractList(); ClearControlForContract(); ModalPopupExtender2.Show(); } } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }
private void GetAllCustomer() { Business.Customer.Customer objCustomer = new Business.Customer.Customer(); Entity.Customer.Customer customer = new Entity.Customer.Customer(); customer.CompanyMasterId_FK = 1; customer.CustomerName = txtName.Text.Trim(); customer.PageIndex = gvCustomerMaster.PageIndex; customer.PageSize = gvCustomerMaster.PageSize; DataSet ds = objCustomer.GetAllCustomer(customer); if (ds.Tables.Count > 0) { gvCustomerMaster.DataSource = ds.Tables[0]; gvCustomerMaster.VirtualItemCount = (ds.Tables[1].Rows.Count > 0) ? Convert.ToInt32(ds.Tables[1].Rows[0]["TotalCount"].ToString()) : 10; gvCustomerMaster.DataBind(); } else { gvCustomerMaster.DataSource = null; gvCustomerMaster.DataBind(); } }
private void PopulateCustomerPurchaseDetails() { customer = objCustomer.CustomerPurchase_GetByCustomerPurchaseId(CustomerPurchaseId); if (customer != null) { try { txtMachineId.Text = customer.MachineId; txtProductSlNo.Text = customer.SerialNo; txtCustomerRemarks.Text = customer.CustomerRemarks; txtContactPerson.Text = customer.ContactPerson; txtAddress.Text = customer.Address; txtMobileNo.Text = customer.MobileNo; txtPhone.Text = customer.PhoneNo; ddlBrand.SelectedValue = Convert.ToString(customer.BrandId); ddlAssignEngineer.SelectedValue = Convert.ToString(customer.AssignEngineer); LoadProduct(); ddlProduct.SelectedValue = Convert.ToString(customer.Productid); txtInstallationDate.Text = (customer.InstallationDate == DateTime.MinValue) ? string.Empty : customer.InstallationDate.ToString("dd MMM yyyy"); } catch { } } }
public static DataTable Customer_Customer_GetByAssignEngineerId(Entity.Customer.Customer customer) { using (DataTable dt = new DataTable()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_Customer_Customer_GetByAssignEngineerId"; if (string.IsNullOrEmpty(customer.CustomerName)) { cmd.Parameters.AddWithValue("@CustomerName", DBNull.Value); } else { cmd.Parameters.AddWithValue("@CustomerName", customer.CustomerName); } if (string.IsNullOrEmpty(customer.EmailId)) { cmd.Parameters.AddWithValue("@EmailId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@EmailId", customer.EmailId); } if (string.IsNullOrEmpty(customer.MobileNo)) { cmd.Parameters.AddWithValue("@MobileNo", DBNull.Value); } else { cmd.Parameters.AddWithValue("@MobileNo", customer.MobileNo); } if (string.IsNullOrEmpty(customer.CustomerCode)) { cmd.Parameters.AddWithValue("@CustomerCode", DBNull.Value); } else { cmd.Parameters.AddWithValue("@CustomerCode", customer.CustomerCode); } if (customer.AssignEngineer == 0) { cmd.Parameters.AddWithValue("@AssignEngineer", DBNull.Value); } else { cmd.Parameters.AddWithValue("@AssignEngineer", customer.AssignEngineer); } using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt); } con.Close(); } } return(dt); } }