protected void lnkOK_Click(object sender, EventArgs e) { SupplierTransaction supp = new SupplierTransaction(); OtherTransaction oth = new OtherTransaction(); if (!(supp.VendorExists(oth.Replace(txtVendorName.Text.Trim())))) { string vUserName = tbUserName.Text.Replace(" ", ""); //if (vUserName.Length > 8) // vUserName = vUserName.Substring(0, 8).ToUpper(); //else // vUserName = vUserName.ToUpper(); if (supp.CheckUser(tbUserName.Text.Trim())) { string randomPwd = RandomPasswordGenerator.GenerateRandomPassword(); int vVendorId = supp.InsertUser(connstring, vUserName, EncryptionHelper.Encrypt(randomPwd), ((int)Constant.USERTYPE.VENDOR).ToString().Trim()); ViewState["sUserID"] = vVendorId; web_usercontrol_mobileno uctrlMobileNo1 = (web_usercontrol_mobileno)FindControl("uctrlMobileNo"); supp.InsertOneTimeSupplier(vVendorId.ToString().Trim(), txtVendorName.Text.Trim(), ((int)Constant.SUPPLIERTYPE.OneTimeSupplier).ToString().Trim(), txtEmailAddress.Text.Trim(), txtAddress1.Text.Trim(), txtAddress2.Text.Trim(), txtContactPerson.Text.Trim(), txtTelephoneNumber.Text.Trim(), uctrlMobileNo1.MobileNumber); supp.SaveCategoriesAndSubCategories(vVendorId, ViewState[Constant.QS_CATEGORYID].ToString(), ViewState[Constant.QS_SUBCATEGORYID].ToString()); string emailOk = ""; if (SendEmail()) { emailOk = " and notified"; } lblMessage.Text = txtVendorName.Text.Trim() + " has been successfully added" + emailOk + "."; lnkClose.Attributes.Add("onclick", "AddSuppliersB('" + vVendorId + "', '" + txtVendorName.Text.Trim() + "');"); DisableFields(); } else { lblMessage.Text = tbUserName.Text.Trim() + " already exists."; } } else { lblMessage.Text = txtVendorName.Text.Trim() + " already exists in the vendor list."; } }
private void SaveSupplierData() { string vSuppliertype = "", vCategory = "", vSubcategory = "", vCompanyname = "", vHeadaddress1 = "", vHeadaddress2 = "", vHeadtel = "", vHeadtelext = "", vHeadfax = "", vBranchaddress1 = "", vBranchaddress2 = "", vBranchtel = "", vBranchtelext = "", vBranchfax = "", vVatregno = "", vTin = "", vPobox = "", vPostalcode = "", vEmail = "", vStandardtermsofpayment = "", vSpecialterms = "", vMinimumordervalue = "", vSalesperson = "", vSalespersontelephone = "", vTypeofbusinessorganization = "", vOwnershipFilipino = "", vOwnershipOther = "", vCompanyclassification = "", vSolesupplierline1 = "", vSolesupplierline2 = "", vSpecialization = "", vKeyPersonnel = "", vKeyPosition = ""; DataTable dtPresentServices = new DataTable(); DataTable dtMajorCustomers = new DataTable(); DataTable dtAffiliatedCompanies = new DataTable(); DataTable dtBanks = new DataTable(); DataTable dtExternalAuditors = new DataTable(); DataTable dtRelatives = new DataTable(); DataTable dtEquipment = new DataTable(); ReadFromXMLFile(ref vSuppliertype, ref vCategory, ref vSubcategory, ref vCompanyname, ref vHeadaddress1, ref vHeadaddress2, ref vHeadtel, ref vHeadtelext, ref vHeadfax, ref vBranchaddress1, ref vBranchaddress2, ref vBranchtel, ref vBranchtelext, ref vBranchfax, ref vVatregno, ref vTin, ref vPobox, ref vPostalcode, ref vEmail, ref vStandardtermsofpayment, ref vSpecialterms, ref vMinimumordervalue, ref vSalesperson, ref vSalespersontelephone, ref vTypeofbusinessorganization, ref vOwnershipFilipino, ref vOwnershipOther, ref vCompanyclassification, ref vSolesupplierline1, ref vSolesupplierline2, ref vSpecialization, ref vKeyPersonnel, ref vKeyPosition, ref dtPresentServices, ref dtMajorCustomers, ref dtAffiliatedCompanies, ref dtBanks, ref dtExternalAuditors, ref dtEquipment, ref dtRelatives); SupplierTransaction s = new SupplierTransaction(); if (!s.VendorExists(connstring, vCompanyname.Trim())) { OtherTransaction oth = new OtherTransaction(); string vUserName = vCompanyname.Replace(" ", ""); if (vUserName.Length > 8) { vUserName = vUserName.Substring(0, 8).ToUpper(); } else { vUserName = vUserName.ToUpper(); } bool IsValidUserName = s.CheckUser(connstring, vUserName.Trim()); while (!IsValidUserName) { int ctr = 0; vUserName = vUserName + ctr.ToString().Trim(); IsValidUserName = s.CheckUser(connstring, vUserName.Trim()); } if (IsValidUserName) { Session["VendorId"] = s.InsertUser(connstring, vUserName, EncryptionHelper.Encrypt(vUserName), ((int)Constant.USERTYPE.VENDOR).ToString().Trim()); } if (Session["VendorId"].ToString().Trim() != "-1") { s.RegisterSupplier(connstring, Session["VendorId"].ToString().Trim(), vCompanyname, vSuppliertype, vEmail, vHeadaddress1, vHeadaddress2, vBranchaddress1, vBranchaddress2, vSalesperson, vSalespersontelephone, "", vHeadtel, vHeadfax, vHeadtelext, vBranchtel, vBranchfax, vBranchtelext, vVatregno, vTin, vPobox, vStandardtermsofpayment, vSpecialterms, vMinimumordervalue, vPostalcode, vOwnershipFilipino, vOwnershipOther, vTypeofbusinessorganization, vSpecialization, vSolesupplierline1, vSolesupplierline2, vKeyPersonnel, vKeyPosition, GetISOStandard(), ddlPCABClass.SelectedItem.Value.Trim()); string[] VendorSubCategory = vSubcategory.Split(Convert.ToChar(",")); s.InsertSubCategory(connstring, Session["VendorId"].ToString().Trim(), VendorSubCategory); string[] VendorCategory = vCategory.Split(Convert.ToChar(",")); s.InsertCategory(connstring, Session["VendorId"].ToString().Trim(), VendorCategory); string[] VendorClassifiction = vCompanyclassification.Split(Convert.ToChar(",")); s.InsertVendorClassification(connstring, Session["VendorId"].ToString().Trim(), VendorClassifiction); s.InsertPresentServices(connstring, Session["VendorId"].ToString().Trim(), dtPresentServices); s.InsertMajorCustomers(connstring, Session["VendorId"].ToString().Trim(), dtMajorCustomers); s.InsertBanks(connstring, Session["VendorId"].ToString().Trim(), dtBanks); s.InsertAffiliatedCompanies(connstring, Session["VendorId"].ToString().Trim(), dtAffiliatedCompanies); s.InsertExternalAuditors(Session["VendorId"].ToString().Trim(), dtExternalAuditors); s.InsertEquipment(connstring, Session["VendorId"].ToString().Trim(), dtEquipment); s.InsertRelative(connstring, Session["VendorId"].ToString().Trim(), dtRelatives); s.InsertBrandsMain(connstring, Session["VendorId"].ToString().Trim(), hdnBrands.Text.Trim()); s.InsertItemsCarriedMain(connstring, Session["VendorId"].ToString().Trim(), hdnItems.Text.Trim()); s.InsertServicesOfferedMain(connstring, Session["VendorId"].ToString().Trim(), hdnServices.Text.Trim()); s.InsertLocationMain(connstring, Session["VendorId"].ToString().Trim(), hdnLocation.Text.Trim()); Session["XMLFile"] = null; Response.Redirect("supplierdetails.aspx"); } else { lblMessage.Text = "Error in inserting user."; } } else { lblMessage.Text = "Supplier already exists."; } }