protected void odsSearchCustomer_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { CustomerManager customerManager = new CustomerManager(this); Hashtable htCustomer = new Hashtable(); htCustomer.Add("CompanyId", Company.MatrixId); htCustomer.Add("SelectedCustomer", txtSelectedCustomer.Text); htCustomer.Add("CPF", txtCPF.Text); htCustomer.Add("CNPJ", txtCNPJ.Text); htCustomer.Add("Email", txtMail.Text); htCustomer.Add("Phone", txtPhone.Text); htCustomer.Add("EquipmentName", txtEquipment.Text); htCustomer.Add("Ranking", rtnRanking.CurrentRating); htCustomer.Add("CustomerTypeId", cboCustomerType.SelectedValue); var represetantUser = new RepresentantManager(this).GetRepresentantUser(User.Identity.UserId); if (represetantUser != null) { htCustomer.Add("representantId", represetantUser.RepresentantId.ToString()); } else { htCustomer.Add("representantId", String.Empty); } e.InputParameters["htCustomer"] = htCustomer; }
protected void odsSaleList_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["customerId"] = null; e.InputParameters["saleStatusId"] = null; e.InputParameters["receiptNumber"] = null; e.InputParameters["companyId"] = Company.CompanyId; e.InputParameters["dateTimeInterval"] = ucDateTimeInterval.DateInterval; e.InputParameters["showCanceled"] = chkShowCanceledSale.Checked; if (!String.IsNullOrEmpty(cboSaleStatus.SelectedValue)) { e.InputParameters["saleStatusId"] = Convert.ToInt32(cboSaleStatus.SelectedValue); } if (Page.ViewState["CustomerId"] != null) { e.InputParameters["customerId"] = Convert.ToInt32(Page.ViewState["CustomerId"]); } if (!String.IsNullOrEmpty(txtFiscalNumber.Text) && txtFiscalNumber.Text.Length <= 9) { e.InputParameters["receiptNumber"] = Convert.ToInt32(txtFiscalNumber.Text); } var representantUser = new RepresentantManager(this).GetRepresentantUser(User.Identity.UserId); if (representantUser != null) { e.InputParameters["representantId"] = representantUser.RepresentantId; } }
protected void odsCustomers_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["companyId"] = Company.MatrixId.Value; var represetantUser = new RepresentantManager(this).GetRepresentantUser(User.Identity.UserId); if (represetantUser != null) e.InputParameters["representantId"] = represetantUser.RepresentantId; e.InputParameters["initialLetter"] = ucAlphabeticalPaging.Letter; }
protected void odsCustomers_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["companyId"] = Company.MatrixId.Value; var represetantUser = new RepresentantManager(this).GetRepresentantUser(User.Identity.UserId); if (represetantUser != null) { e.InputParameters["representantId"] = represetantUser.RepresentantId; } e.InputParameters["initialLetter"] = ucAlphabeticalPaging.Letter; }
public static bool DeleteRepresentant(int representantid) { bool result = true; using (RepresentantManager representantManager = new RepresentantManager(null)) { try { representantManager.Delete(representantManager.GetRepresentant(representantid)); } catch (System.Data.SqlClient.SqlException e) { result = false; } } return(result); }
/// <summary> /// this method return true if the representant exist /// </summary> /// <returns></returns> private bool ExistRepresentant() { Boolean existRepresentant = false; manager = new RepresentantManager(this); if (manager.GetRepresentantByProfile(Company.CompanyId, Convert.ToInt32(Page.ViewState["ProfileId"])) != null) { existRepresentant = true; } if (manager.GetRepresentantByProfile(Company.CompanyId, Convert.ToInt32(Page.ViewState["LegalEntityProfileId"])) != null) { existRepresentant = true; } return(existRepresentant); }
protected void odsSaleList_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["customerId"] = null; e.InputParameters["saleStatusId"] = null; e.InputParameters["receiptNumber"] = null; e.InputParameters["companyId"] = Company.CompanyId; e.InputParameters["dateTimeInterval"] = ucDateTimeInterval.DateInterval; e.InputParameters["showCanceled"] = chkShowCanceledSale.Checked; if (!String.IsNullOrEmpty(cboSaleStatus.SelectedValue)) e.InputParameters["saleStatusId"] = Convert.ToInt32(cboSaleStatus.SelectedValue); if (Page.ViewState["CustomerId"] != null) e.InputParameters["customerId"] = Convert.ToInt32(Page.ViewState["CustomerId"]); if (!String.IsNullOrEmpty(txtFiscalNumber.Text) && txtFiscalNumber.Text.Length <= 9) e.InputParameters["receiptNumber"] = Convert.ToInt32(txtFiscalNumber.Text); var representantUser = new RepresentantManager(this).GetRepresentantUser(User.Identity.UserId); if (representantUser != null) e.InputParameters["representantId"] = representantUser.RepresentantId; }
public static bool DeleteRepresentant(int representantid) { bool result = true; using (RepresentantManager representantManager = new RepresentantManager(null)) { try { representantManager.Delete(representantManager.GetRepresentant(representantid)); } catch (System.Data.SqlClient.SqlException e) { result = false; } } return result; }
/// <summary> /// This method adds a representant to user /// </summary> /// <param name="companyId"></param> /// <param name="userId"></param> /// <param name="representantId"></param> public void AddRepresentantToUser(Int32 companyId, Int32 userId, Int32 representantId) { var representantManager = new RepresentantManager(this); var representantUser = new RepresentantUser { CompanyId = companyId, UserId = userId, RepresentantId = representantId }; representantManager.InsertRepresentantUser(representantUser); }
/// <summary> /// This method removes a representant from user /// </summary> /// <param name="userId"></param> public void RemoveRepresentantFromUser(Int32 userId) { var representantManager = new RepresentantManager(this); if (representantManager.GetRepresentantUser(userId) != null) representantManager.DeleteRepresentantUser(userId); }
/// <summary> /// this method return true if the representant exist /// </summary> /// <returns></returns> private bool ExistRepresentant() { Boolean existRepresentant = false; manager = new RepresentantManager(this); if (manager.GetRepresentantByProfile(Company.CompanyId, Convert.ToInt32(Page.ViewState["ProfileId"])) != null) existRepresentant = true; if (manager.GetRepresentantByProfile(Company.CompanyId, Convert.ToInt32(Page.ViewState["LegalEntityProfileId"])) != null) existRepresentant = true; return existRepresentant; }
protected void Page_Load(object sender, EventArgs e) { manager = new RepresentantManager(this); //retrieve the RepresentantId from Modal Popup if (!String.IsNullOrEmpty(Request["RepresentantId"])) { Page.ViewState["RepresentantId"] = Request["RepresentantId"]; lblRepresentantCode.Visible = true; lblRepresentantCode.Text = "Código do Representante: " + Request["RepresentantId"]; } if (Context.Items["RepresentantId"] != null) Page.ViewState["RepresentantId"] = Context.Items["RepresentantId"]; if (Page.ViewState["RepresentantId"] != null) { original_representant = manager.GetRepresentant(Convert.ToInt32(Page.ViewState["RepresentantId"])); if (!IsPostBack && original_representant != null) { /* * The code below checks the type of profile(LegalEntityProfile/Profile) */ if (original_representant.LegalEntityProfile != null) Profile1.CompanyProfileEntity = original_representant.LegalEntityProfile; else Profile1.ProfileEntity = original_representant.Profile; // //load bank informations // if (original_representant.BankId.HasValue) cboBank.SelectedValue = Convert.ToString(original_representant.BankId); txtAccountNumber.Text = original_representant.AccountNumber; txtAgency.Text = original_representant.Agency; // //load ranking value // if (original_representant.Rating != null) rtnRating.CurrentRating = Convert.ToInt32(original_representant.Rating); } } else { // // Legal Entity // if (Page.ViewState["LegalEntityProfileId"] != null) { original_representant = manager.GetRepresentantByLegalEntityProfile(Company.CompanyId, Convert.ToInt32(Page.ViewState["LegalEntityProfileId"])); if (original_representant != null) { Page.ViewState["ProfileExists"] = "0"; /* * if isn't a postback set the values of company in profile_LegalEntity1 * else the values are reload in all postback * */ if (!IsPostBack) Profile1.CompanyProfileEntity = original_representant.LegalEntityProfile; } } // // Natural Person // if (Page.ViewState["ProfileId"] != null) { original_representant = manager.GetRepresentantByProfile(Company.CompanyId, Convert.ToInt32(Page.ViewState["ProfileId"])); if (original_representant != null) { Page.ViewState["ProfileExists"] = "0"; /*if isn't a postback set the values of company in profile * else the values are reload in all postback */ if (!IsPostBack) Profile1.ProfileEntity = original_representant.Profile; } } if (original_representant != null) Page.ViewState["RepresentantId"] = original_representant.RepresentantId; } }
protected void btnSave_Click(object sender, EventArgs e) { representant = new Representant(); manager = new RepresentantManager(this); // // Clone the original representant for the linq track changes // if (Page.ViewState["RepresentantId"] != null) { original_representant = manager.GetRepresentant(Convert.ToInt32(Page.ViewState["RepresentantId"])); representant.CopyPropertiesFrom(original_representant); } representant.ModifiedDate = DateTime.Now; representant.CompanyId = Company.CompanyId; // //fill fields of account // if (!String.IsNullOrEmpty(cboBank.SelectedValue)) representant.BankId = Convert.ToInt32(cboBank.SelectedValue); else representant.BankId = null; if (!String.IsNullOrEmpty(txtAccountNumber.Text)) representant.AccountNumber = txtAccountNumber.Text; else representant.AccountNumber = null; if (!String.IsNullOrEmpty(txtAgency.Text)) representant.Agency = txtAgency.Text; else representant.Agency = null; // //fill rating value // representant.Rating = rtnRating.CurrentRating; if (Profile1.ProfileEntity != null) { representant.ProfileId = Profile1.ProfileEntity.ProfileId; if (representant.ProfileId == 0) representant.Profile = Profile1.ProfileEntity; } else { representant.LegalEntityProfileId = Profile1.CompanyProfileEntity.LegalEntityProfileId; if (representant.LegalEntityProfileId == 0) representant.LegalEntityProfile = Profile1.CompanyProfileEntity; } if (Page.ViewState["RepresentantId"] == null && Page.ViewState["ProfileExists"] != "0") manager.Insert(representant); else manager.update(original_representant, representant); if (!String.IsNullOrEmpty(Request["RepresentantId"])) Response.Redirect("Representants.aspx"); else Response.Redirect("Representant.aspx?RepresentantId=" + representant.RepresentantId); }
protected void Page_Load(object sender, EventArgs e) { manager = new RepresentantManager(this); //retrieve the RepresentantId from Modal Popup if (!String.IsNullOrEmpty(Request["RepresentantId"])) { Page.ViewState["RepresentantId"] = Request["RepresentantId"]; lblRepresentantCode.Visible = true; lblRepresentantCode.Text = "Código do Representante: " + Request["RepresentantId"]; } if (Context.Items["RepresentantId"] != null) { Page.ViewState["RepresentantId"] = Context.Items["RepresentantId"]; } if (Page.ViewState["RepresentantId"] != null) { original_representant = manager.GetRepresentant(Convert.ToInt32(Page.ViewState["RepresentantId"])); if (!IsPostBack && original_representant != null) { /* * The code below checks the type of profile(LegalEntityProfile/Profile) */ if (original_representant.LegalEntityProfile != null) { Profile1.CompanyProfileEntity = original_representant.LegalEntityProfile; } else { Profile1.ProfileEntity = original_representant.Profile; } // //load bank informations // if (original_representant.BankId.HasValue) { cboBank.SelectedValue = Convert.ToString(original_representant.BankId); } txtAccountNumber.Text = original_representant.AccountNumber; txtAgency.Text = original_representant.Agency; // //load ranking value // if (original_representant.Rating != null) { rtnRating.CurrentRating = Convert.ToInt32(original_representant.Rating); } } } else { // // Legal Entity // if (Page.ViewState["LegalEntityProfileId"] != null) { original_representant = manager.GetRepresentantByLegalEntityProfile(Company.CompanyId, Convert.ToInt32(Page.ViewState["LegalEntityProfileId"])); if (original_representant != null) { Page.ViewState["ProfileExists"] = "0"; /* * if isn't a postback set the values of company in profile_LegalEntity1 * else the values are reload in all postback * */ if (!IsPostBack) { Profile1.CompanyProfileEntity = original_representant.LegalEntityProfile; } } } // // Natural Person // if (Page.ViewState["ProfileId"] != null) { original_representant = manager.GetRepresentantByProfile(Company.CompanyId, Convert.ToInt32(Page.ViewState["ProfileId"])); if (original_representant != null) { Page.ViewState["ProfileExists"] = "0"; /*if isn't a postback set the values of company in profile * else the values are reload in all postback */ if (!IsPostBack) { Profile1.ProfileEntity = original_representant.Profile; } } } if (original_representant != null) { Page.ViewState["RepresentantId"] = original_representant.RepresentantId; } } }
protected void btnSave_Click(object sender, EventArgs e) { representant = new Representant(); manager = new RepresentantManager(this); // // Clone the original representant for the linq track changes // if (Page.ViewState["RepresentantId"] != null) { original_representant = manager.GetRepresentant(Convert.ToInt32(Page.ViewState["RepresentantId"])); representant.CopyPropertiesFrom(original_representant); } representant.ModifiedDate = DateTime.Now; representant.CompanyId = Company.CompanyId; // //fill fields of account // if (!String.IsNullOrEmpty(cboBank.SelectedValue)) { representant.BankId = Convert.ToInt32(cboBank.SelectedValue); } else { representant.BankId = null; } if (!String.IsNullOrEmpty(txtAccountNumber.Text)) { representant.AccountNumber = txtAccountNumber.Text; } else { representant.AccountNumber = null; } if (!String.IsNullOrEmpty(txtAgency.Text)) { representant.Agency = txtAgency.Text; } else { representant.Agency = null; } // //fill rating value // representant.Rating = rtnRating.CurrentRating; if (Profile1.ProfileEntity != null) { representant.ProfileId = Profile1.ProfileEntity.ProfileId; if (representant.ProfileId == 0) { representant.Profile = Profile1.ProfileEntity; } } else { representant.LegalEntityProfileId = Profile1.CompanyProfileEntity.LegalEntityProfileId; if (representant.LegalEntityProfileId == 0) { representant.LegalEntityProfile = Profile1.CompanyProfileEntity; } } if (Page.ViewState["RepresentantId"] == null && Page.ViewState["ProfileExists"] != "0") { manager.Insert(representant); } else { manager.update(original_representant, representant); } if (!String.IsNullOrEmpty(Request["RepresentantId"])) { Response.Redirect("Representants.aspx"); } else { Response.Redirect("Representant.aspx?RepresentantId=" + representant.RepresentantId); } }
protected void odsSearchCustomer_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { CustomerManager customerManager = new CustomerManager(this); Hashtable htCustomer = new Hashtable(); htCustomer.Add("CompanyId", Company.MatrixId); htCustomer.Add("SelectedCustomer", txtSelectedCustomer.Text); htCustomer.Add("CPF", txtCPF.Text); htCustomer.Add("CNPJ", txtCNPJ.Text); htCustomer.Add("Email", txtMail.Text); htCustomer.Add("Phone", txtPhone.Text); htCustomer.Add("EquipmentName", txtEquipment.Text); htCustomer.Add("Ranking", rtnRanking.CurrentRating); htCustomer.Add("CustomerTypeId", cboCustomerType.SelectedValue); var represetantUser = new RepresentantManager(this).GetRepresentantUser(User.Identity.UserId); if (represetantUser != null) htCustomer.Add("representantId", represetantUser.RepresentantId.ToString()); else htCustomer.Add("representantId", String.Empty); e.InputParameters["htCustomer"] = htCustomer; }