Esempio n. 1
0
        public void InsertRecordBody(Objects.BankIssueBody obj)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SP_BankIssueBodyInsert";

                cmd.Parameters.AddWithValue("@IssueID", obj.IssueID);
                cmd.Parameters.AddWithValue("@AccountNo", obj.AccountNo);
                cmd.Parameters.AddWithValue("@Amount", obj.Amount);

                new Database(connectionstring).ExecuteNonQueryOnly(cmd);
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string vMessage = string.Empty;

                if (txtCheqNo.Text.Trim() == string.Empty)
                {
                    vMessage = "Please Enter Cheque Number.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtCheqNo.Focus();
                    return;
                }

                if (txtBankAccName.Text.Trim() == string.Empty)
                {
                    vMessage = "Please Select Bank Account.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtBankAccNo.Focus();
                    return;
                }

                Int64 vAmount, vChqAmount, vWHTAmnt;

                Int64.TryParse(txtTotalAmount.Text, out vAmount);
                Int64.TryParse(txtTotalCheqAmount.Text, out vChqAmount);
                Int64.TryParse(txtWHTAmount.Text, out vWHTAmnt);

                if (vAmount != vChqAmount)
                {
                    vMessage = "Amount Detail not equal to Total Cheques Amount.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtAccountNo.Focus();
                    return;
                }

                if (Grid.Rows.Count == 0)
                {
                    vMessage = "Amount Detail not entered.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtAccountNo.Focus();
                    return;
                }


                Int64.TryParse(txtChqAmount.Text, out vChqAmount);

                Objects.BankIssues obj = new Objects.BankIssues();
                obj.IssueID       = Int64.Parse(txtID.Text);
                obj.IssueDate     = dtDepositDate.Value;
                obj.BankAccountNo = txtBankAccNo.Text;
                obj.Amount        = vChqAmount;
                obj.WHTAccountNo  = "200000";
                obj.WHTAmount     = vWHTAmnt;
                obj.ReceivedBy    = txtReceivedby.Text;
                obj.Narration     = txtNarration.Text;

                DAL.Settings obSet = new DAL.Settings();
                obSet.connectionstring = objDAL.connectionstring;
                obj.IsPosted           = Convert.ToBoolean(obSet.GetSettingValue(DAL.Settings.ProSettings.IsAutoPost));

                obj.UserID    = vUserID;
                obj.EntryDate = DateTime.Now.Date;

                obj.ChequeDate = dtCheqDate.Value;
                obj.ChequeNo   = txtCheqNo.Text;
                obj.IsLost     = false;



                if (!vOpenMode)
                {
                    //Insert Activity
                    obj.IssueID = Int64.Parse(objDAL.getNextNo().ToString());
                    objDAL.DeleteRecordBody(obj.IssueID);

                    objDAL.InsertRecord(obj);
                }
                else
                {
                    objDAL.DeleteRecordBody(obj.IssueID);
                    objDAL.UpdateRecord(obj);
                }

                //Save Detail
                foreach (DataGridViewRow dr in Grid.Rows)
                {
                    if (dr.Cells[0].Value != null)
                    {
                        Objects.BankIssueBody objDon = new Objects.BankIssueBody();
                        objDon.IssueID   = obj.IssueID;
                        objDon.AccountNo = dr.Cells["AccountNo"].Value.ToString();
                        objDon.Amount    = decimal.Parse(dr.Cells["Amount"].Value.ToString());
                        objDAL.InsertRecordBody(objDon);
                    }
                }

                vMessage = "Record Saved Successfully.";
                new Speak().SayIt(vMessage);
                MessageBox.Show(vMessage, "Confirmation");
                PrintVoucher(obj.IssueID);
                btnClear_Click(sender, e);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message.ToString(), "Error");
            }
        }