protected void btnSave_Click(object sender, EventArgs e) { try { Designation newDesignation = new Designation(); bool chk = false; Employee aEmployee = new Employee(); Addresses aAddresses=new Addresses(); List<Employee> employeeListC =aEmployee.GetAllEmployee(_company.CompanyId); if (lblId.Text == "" || lblId.Text == "0") foreach (Employee anEmployee in employeeListC) { if (anEmployee.EmployeeCode == txtEmployeeCode.Value) { Session["empMessage"] = "Employee Code is exist! Try Again"; chk = true; break; } } if (chk == true) { Response.Redirect(Request.RawUrl); } Employee tempEmployee = new Employee(); aEmployee.EmployeeCode = txtEmployeeCode.Value; aEmployee.EmployeeName = txtEmployeeName.Value; aEmployee.DOB = RadDatePicker1.SelectedDate.ToString(); aEmployee.JoinDate = JoinRadDatePicker.SelectedDate.ToString(); aEmployee.DepartmentId = int.Parse(departmentDropDownList.SelectedIndex>-1?departmentDropDownList.SelectedItem.Value:"0"); aEmployee.DesignationId = int.Parse(designationDropDownList.SelectedItem.Value); aEmployee.Address = "Main Address"; aAddresses.SourceType = "Employee"; aAddresses.AddressLine1 = txtAddressLine1.Value; aAddresses.AddressLine2 = txtAddressLine2.Value; aAddresses.AddressType = "Main Address"; aAddresses.CountryId = int.Parse(countryDropDownList.SelectedIndex.ToString()); aAddresses.City = txtCity.Value; aAddresses.ZipCode = txtZipCode.Value; aAddresses.Email = txtEmail.Value; aAddresses.Web = ""; aAddresses.Phone = txtPhoneNo.Value; aAddresses.Mobile = txtMobile.Value; aAddresses.CompanyId = _company.CompanyId; aEmployee.CompanyId = _company.CompanyId; aEmployee.IsActive = true; aEmployee.UpdateBy = user.UserId; aEmployee.UpdateDate = DateTime.Now; if (lblId.Text == "" || lblId.Text == "0") { aEmployee.EmployeeId = new Employee().GetMaxEmployeeId() + 1; aAddresses.SourceId = aEmployee.EmployeeId; aAddresses.AddressId = new Addresses().GetMaxAddressId() + 1; int chkEmployee = aEmployee.InsertEmployee(); int chkAddress = aAddresses.InsertAddresses(); if (chkAddress > 0 && chkEmployee > 0) { Session["empMessage"] = "Saved Successfully"; Response.Redirect(Request.RawUrl); } else { Alert.Show("Error occured while inserting employee information"); } } else { aEmployee.EmployeeId = int.Parse(lblId.Text); aAddresses.SourceId = aEmployee.EmployeeId; aAddresses.AddressId = long.Parse(addlblId.Text); int chk3= aEmployee.UpdateEmployee(); int chk1=aAddresses.UpdateAddresses(); if(chk3>0&&chk1>0) Response.Redirect("EmployeeList.aspx",true); } } catch (Exception exp) { Alert.Show(exp.Message); } }
protected void btnSave_Click(object sender, EventArgs e) { try { bool chk = false; Supplier aSupply = new Supplier(); List<Supplier> aSuppierList = aSupply.GetAllSupplier(_company.CompanyId); long id; Supplier newSupply = new Supplier(); newSupply.SupplierName = txtSupplierName.Value; newSupply.IsActive = true; newSupply.CompanyId = _company.CompanyId; newSupply.UpdateBy = user.UserId; newSupply.UpdateDate = DateTime.Now; newSupply.TotalDebit = decimal.Parse(txtTotalDebit.Value); newSupply.TotalCredit = decimal.Parse(txtTotalCredit.Value); Addresses address = new Addresses(); address.SourceType = "Supplier"; address.AddressType = "Main Address"; address.AddressLine1 = txtAddressLine1.Value; address.AddressLine2 = txtAddressLine2.Value; address.CountryId = int.Parse(countryDropDownList.SelectedIndex.ToString()); address.City = txtCity.Value; address.Email = txtEmail.Value; address.Phone = txtPhone.Value; address.Web = txtWeb.Value; address.Mobile = txtMobile.Value; address.ZipCode = txtZipCode.Value; address.CompanyId = _company.CompanyId; if (lblId.Text == "" || lblId.Text == "0") { newSupply.SupplierId = new Supplier().GetMaxSupplierID() + 1; address.SourceId = newSupply.SupplierId; address.AddressId = new Addresses().GetMaxAddressId() + 1; int chk1 = newSupply.InsertSupplier(); int chk2 = address.InsertAddresses(); if (chk1 > 0 && chk2 > 0) { Session["savedSupplicerMessage"] = "Saved Successfully"; Response.Redirect(Request.RawUrl); } else { Alert.Show("Error occured while inserting supplier information,please check the input data again. Don't use special character in Debit or Credit Section . Use the amount number there."); } } else { address.AddressId = long.Parse(addlblId.Text); newSupply.SupplierId = int.Parse(lblId.Text); address.SourceId = newSupply.SupplierId; int chk1 = newSupply.UpdateSupplier(); int chk2 = address.UpdateAddresses(); if(chk1>0&&chk2>0) Response.Redirect("SupplierList.aspx"); } } catch (Exception exp) { Alert.Show(exp.Message); } }
protected void btnSave_Click(object sender, EventArgs e) { Customer objCustomer = new Customer(); objCustomer.CustomerName = txtCustomerName.Value; objCustomer.CustomerCategoryId = int.Parse(txtCustomerCategory.Value); objCustomer.SalesPersonId = int.Parse(salesPersonDropDownList.SelectedItem.Value); objCustomer.IsActive = chkIsActive.Checked; objCustomer.CompanyId = _company.CompanyId; objCustomer.CreditLimit = int.Parse(txtCreditLimit.Value); objCustomer.UpdateBy = _user.UserId; objCustomer.UpdateDate = DateTime.Now; Addresses address = new Addresses(); address.SourceType = "Customer"; address.AddressType = "Main Address"; address.AddressLine1 = txtAddressLine1.Value; address.AddressLine2 = txtAddressLine2.Value; address.CountryId = countryDropDownList.SelectedIndex; address.City = txtCity.Value; address.ZipCode = txtZipCode.Value; address.Phone = txtPhoneNo.Value; address.Mobile = txtMobile.Value; address.Email = txtEmail.Value; address.Web = txtWeb.Value; address.CompanyId = _company.CompanyId; if ((lblId.Text == "" || lblId.Text == "0") && (addlblId.Text == "" || addlblId.Text == "0")) { objCustomer.CustomerId = new Customer().GetMaxCustomerID() + 1; address.SourceId = objCustomer.CustomerId; address.AddressId = new Addresses().GetMaxAddressId() + 1; int chk1 = objCustomer.InsertCustomer(); int chk2 = address.InsertAddresses(); if (chk1 > 0 && chk2 > 0) { Session["savedCutomerMessage"] = "Saved Successfully"; Response.Redirect(Request.RawUrl); } else { Alert.Show("Error occured while inserting customer information"); } } else { address.AddressId =long.Parse( addlblId.Text); objCustomer.CustomerId = long.Parse(lblId.Text); int check = address.UpdateAddresses(); check = objCustomer.UpdateCustomer(); if (check > 0) { Response.Redirect("CustomerList.aspx", true); } } }
protected void btnSave_Click(object sender, EventArgs e) { try { if (txtCompanyName.Value == string.Empty) { Alert.Show("Please enter the company name."); txtCompanyName.Focus(); return; } Company newCompany = new Company(); newCompany.CompanyName = txtCompanyName.Value; newCompany.Address = ""; newCompany.Phone = ""; newCompany.Email = ""; newCompany.Web = ""; newCompany.LogoPath = txtLogoPath.Value; // newCompany.UpdateBy = user.UserId; newCompany.UpdateBy = _user.UserId; newCompany.UpdateDate = DateTime.Now; newCompany.IsActive = chkIsActive.Checked; Addresses address = new Addresses(); address.SourceType = "Company"; address.AddressType = "Main Address"; address.AddressLine1 = txtAddressLine1.Value; address.AddressLine2 = txtAddressLine2.Value; address.CountryId = countryDropDownList.SelectedIndex; address.City = txtCity.Value; address.ZipCode = txtZipCode.Value; address.Phone = txtPhoneNo.Value; address.Mobile = txtPhoneNo.Value; address.Email = txtEmail.Value; address.Web = txtWeb.Value; address.CompanyId = _user.CompanyId; if (lblId.Text == "" || lblId.Text == "0") { newCompany.CompanyId = new Company().GetMaxCompanyId() + 1; address.SourceId = newCompany.CompanyId; address.AddressId = new Addresses().GetMaxAddressId() + 1; int success = newCompany.InsertCompany(); address.InsertAddresses(); if (success > 0) { Alert.Show("Saved Company Information Successfully!"); this.LoadAllCompany(); this.Clear(); } else { Alert.Show("Error occured !"); } } else { newCompany.CompanyId = int.Parse(lblId.Text); address.SourceId = newCompany.CompanyId; address.AddressId = long.Parse(addlblId.Text); int chk1 = newCompany.UpdateCompany(); int chk2 = address.UpdateAddresses(); if (chk1 > 0||chk2>0) { Response.Redirect("CompanyList.aspx", true); } } } catch (Exception ex) { Alert.Show(ex.Message); } }