Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        private void CmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (TxtName.Text.Trim() == string.Empty)
                {
                    //MessageBox.Show(exc.Message);

                    TxtName.Focus();
                    return;
                }


                Objects.Salesmen obj = new Objects.Salesmen();
                obj.SalesmanID   = TxtPrefix.Text + " " + TxtID.Text;
                obj.SalesmanName = TxtName.Text.Trim();
                obj.Address      = TxtAddress.Text.Trim();
                obj.Phone        = txtPhone1.Text.Trim();
                obj.City         = TxtCity.Text.Trim();
                obj.Mobile       = txtMobileNo.Text.Trim();
                obj.NIC          = txtNIC.Text.Trim();
                // obj.CommissionRatio = decimal.Parse(txtCommisionRatio.Text.ToString());
                int vCommRatio;
                int.TryParse(txtCommisionRatio.Text, out vCommRatio);

                obj.CommissionRatio = vCommRatio;
                obj.IsStockHolder   = chkStockHolder.Checked;
                obj.IsStaff         = chkStaff.Checked;
                obj.OfficeID        = int.Parse(CmbOffice.SelectedValue.ToString());
                obj.Designation     = txtDesignation.Text.Trim();

                // decimal vOpDebit = 0;
                //decimal vOpCredit = 0;

                //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       = obj.SalesmanID;
                objAcc.AccountName     = obj.SalesmanName;
                objAcc.AccountType     = "Parties";
                objAcc.InActive        = true;
                objAcc.AccountDepth    = 1;
                objAcc.AccountNameUrdu = "";
                objAcc.Narration       = "";
                objAcc.OfficeID        = Int32.Parse(CmbOffice.SelectedValue.ToString());
                objAcc.OpeningDebit    = 0;
                objAcc.OpeningCredit   = 0;
                objAcc.ParentAccountNo = "63";

                objAcc.ResidualValue  = 0;
                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 vCommissionRatio;
                decimal.TryParse(txtCommisionRatio.Text, out vCommissionRatio);


                objAcc.Life   = vCommissionRatio;
                objAcc.PLFlag = "";
                objAcc.UserNo = 1;


                if (!vOpenMode)
                {
                    objAcc.AccountNo = obj.SalesmanID; //objDAL.getNextNo().ToString();
                    AccDAL.InsertRecord(objAcc);
                    objDAL.InsertRecord(obj);
                }
                else
                {
                    objDAL.UpdateRecord(obj);
                }

                MessageBox.Show("SaveRecord");
                LoadGrid();
                CmdClear_Click(sender, e);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }