Example #1
0
        public void UpdateRecord(Objects.Salesmen obj)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SP_SalesmenUpdate";

                cmd.Parameters.AddWithValue("@SalesmanID", obj.SalesmanID);
                cmd.Parameters.AddWithValue("@SalesmanName", obj.SalesmanName);
                cmd.Parameters.AddWithValue("@Address", obj.Address);
                cmd.Parameters.AddWithValue("@City", obj.City);
                cmd.Parameters.AddWithValue("@Phone", obj.Phone);
                cmd.Parameters.AddWithValue("@Mobile", obj.Mobile);
                cmd.Parameters.AddWithValue("@NIC", obj.NIC);
                cmd.Parameters.AddWithValue("@CommissionRatio", obj.CommissionRatio);
                cmd.Parameters.AddWithValue("@OfficeID", obj.OfficeID);
                cmd.Parameters.AddWithValue("@IsStockHolder", obj.IsStockHolder);
                cmd.Parameters.AddWithValue("@Designation", obj.Designation);
                cmd.Parameters.AddWithValue("@IsStaff", obj.IsStaff);


                new Database(connectionstring).ExecuteNonQueryOnly(cmd);
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Example #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);
            }
        }