private void CmdSave_Click(object sender, EventArgs e) { try { if (txtName.Text.Trim() == string.Empty) { MessageBox.Show("Please Enter Party Name."); txtName.Focus(); return; } Objects.Parties obj = new Objects.Parties(); obj.PartyID = TxtPrefix.Text + "" + TxtID.Text; obj.PartyName = txtName.Text.Trim(); obj.Phone1 = txtPhone1.Text.Trim(); obj.Phone2 = txtPhone2.Text.Trim(); obj.City = TxtCity.Text.Trim(); obj.Address = TxtAddress.Text.Trim(); obj.EMail = txtEmail.Text.Trim(); int vDueDays; int.TryParse(txtDueDays.Text, out vDueDays); obj.DueDays = vDueDays; int vDiscRatio; int.TryParse(txtDiscRatio.Text, out vDiscRatio); obj.DiscRatio = vDiscRatio; obj.Description = txtDescription.Text.Trim(); obj.ContactPerson = txtContactPerson.Text.Trim(); obj.OfficeID = int.Parse(CmbOffice.SelectedValue.ToString()); obj.SectorID = int.Parse(CmbSector.SelectedValue.ToString()); obj.GroupID = int.Parse(CmbGroups.SelectedValue.ToString());// idher name likhain grou obj.Mobile = txtMobileNo.Text.Trim(); obj.Fax = txtFax.Text.Trim(); obj.InActive = ChkInActive.Checked; // obj. = ChkVendor.Checked; if (ChkVendor.Checked == true) { obj.PartyType = "V"; } else { obj.PartyType = "C"; } decimal vDebitLimit = 0; decimal vCreditLimit = 0; decimal.TryParse(this.txtDebitLimit.Text, out vDebitLimit); decimal.TryParse(this.txtCreditLimit.Text, out vCreditLimit); obj.CreditLimit = vCreditLimit; obj.DebitLimit = vDebitLimit; //Insert Account var AccDAL = new DAL.ChartOfAccounts(); AccDAL.connectionstring = objDAL.connectionstring; Objects.ChartOfAccounts objAcc = new Objects.ChartOfAccounts(); if (!string.IsNullOrEmpty(TxtID.Tag.ToString())) { objAcc.AccountNo = TxtID.Tag.ToString(); } objAcc.AccountName = obj.PartyName; objAcc.AccountType = "Parties"; objAcc.InActive = true; objAcc.AccountDepth = 2; objAcc.AccountNameUrdu = txtNameUrdu.Text.Trim(); objAcc.Narration = txtDescription.Text.Trim(); objAcc.OfficeID = Int32.Parse(CmbOffice.SelectedValue.ToString()); objAcc.OpeningDebit = vDebitLimit; objAcc.OpeningCredit = vCreditLimit; objAcc.ParentAccountNo = "62"; objAcc.ResidualValue = decimal.Parse(vDueDays.ToString()); objAcc.IsDetailed = false; objAcc.IsSold = false; objAcc.EntryDate = DateTime.Now; objAcc.AdjustedCredit = 0; objAcc.AdjustedDebit = 0; objAcc.BalFlag = false; objAcc.ExpFlag = false; objAcc.IsEditable = false; objAcc.IsLocked = false; objAcc.IsPosted = false; decimal vDisRatio; decimal.TryParse(txtDiscRatio.Text, out vDisRatio); objAcc.Life = vDisRatio; objAcc.PLFlag = Convert.ToBoolean(obj.PayablesFlag).ToString(); objAcc.UserNo = 1; if (!vOpenMode) { objAcc.AccountNo = obj.PartyID; //objDAL.getNextNo().ToString(); AccDAL.InsertRecord(objAcc); //Insert Party // obj.PartyID = objDAL.getNextNo().ToString (); // obj.AccountID= objAcc.AccountNo; objDAL.InsertRecord(obj); } else { // UPdate Opeinig in Account // AccDAL.UpdateRecord(objAcc); objDAL.UpdateRecord(obj); } MessageBox.Show("SaveRecord"); LoadGrid(); CmdClear_Click(sender, e); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
private void cmdSave_Click(object sender, RoutedEventArgs e) { try { if (txtName.Text.Trim() == string.Empty) { MessageBox.Show("Please Enter Party Name."); txtName.Focus(); return; } Objects.Parties obj = new Objects.Parties(); obj.PartyID = Int64.Parse(txtId.Text); obj.PartyName = txtName.Text.Trim(); obj.ContactNo = txtContactNo.Text.Trim(); obj.CNICNo = txtCNIC.Text.Trim(); obj.City = txtCity.Text.Trim(); obj.Address = txtAddress.Text.Trim(); obj.Email = txtEmail.Text.Trim(); obj.Web = txtWeb.Text.Trim(); obj.NTN = txtNTN.Text.Trim(); obj.AccountID = txtId.Tag.ToString(); //obj.IsSupplier = chkSupplier; //obj.IsCustomer = chkCustomer.Checked; obj.IsSupplier = true; obj.IsCustomer = true; //decimal vOpDebit = 0; //decimal vOpCredit = 0; //decimal.TryParse(this.txtOpDebit.Text, out vOpDebit); //decimal.TryParse(this.txtOpCredit.Text, out vOpCredit); //Insert Account //var AccDAL = new DAL.AccountChart(); //AccDAL.connectionstring = objDAL.connectionstring; //Objects.AccountChart objAcc = new Objects.AccountChart(); //if (!string.IsNullOrEmpty(txtId.Tag.ToString())) // objAcc.AccountNo = txtId.Tag.ToString(); //objAcc.AccountTitle = obj.PartyName; //objAcc.AccountType = "ASSET"; //objAcc.AccountSubType = "Parties"; //objAcc.IsParty = true; //objAcc.IsBank = false; //objAcc.OpeningDebit = vOpDebit; //objAcc.OpeningCredit = vOpCredit; if (!vOpenMode) { //objAcc.AccountNo = AccDAL.getNextNo("ASSET").ToString(); //AccDAL.InsertRecord(objAcc); ////Insert Party //obj.PartyID = objDAL.getNextNo(); //obj.AccountID = objAcc.AccountNo; objDAL.InsertRecord(obj); } else { // UPdate Opeinig in Account //AccDAL.UpdateRecord(objAcc); objDAL.UpdateRecord(obj); } MessageBox.Show("SaveRecord"); //LoadGrid(); //btnClear_Click(sender, e); } catch (Exception exc) { MessageBox.Show("Error", exc.Message); } }