Beispiel #1
0
        public void UpdateRecord(Objects.VoucherHeader obj)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SP_VoucherHeaderUpdate";

                cmd.Parameters.AddWithValue("@VoucherID", obj.VoucherID);
                cmd.Parameters.AddWithValue("@VoucherType", obj.VoucherType);
                cmd.Parameters.AddWithValue("@VoucherDate", obj.VoucherDate);
                cmd.Parameters.AddWithValue("@Narration", obj.Narration);
                cmd.Parameters.AddWithValue("@IsPosted", obj.IsPosted);
                cmd.Parameters.AddWithValue("@UserID", obj.UserID);
                cmd.Parameters.AddWithValue("@EntryDate", obj.EntryDate);
                cmd.Parameters.AddWithValue("@PrintVoucherType", obj.PrintVoucherType);

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

                if (cboVoucherType.Text == string.Empty)
                {
                    Message.ShowMessage(MyMessages.MessageType.MissingInfo, "Please Select a Voucher Type");
                    cboVoucherType.Focus();
                    return;
                }

                if (Grid.Rows.Count == 0)
                {
                    Message.ShowMessage(MyMessages.MessageType.MissingInfo, "Please Insert Accounts Information");
                    txtAccountNo.Focus();
                    return;
                }

                if (getVoucherType() == "JV")
                {
                    if (txtTotalCredit.Text != txtTotalDebit.Text)
                    {
                        Message.ShowMessage(MyMessages.MessageType.MissingInfo, "Total Debit and Credit not Equal!!! ");
                        txtAccountNo.Focus();
                        return;
                    }
                }


                Objects.VoucherHeader BAL = new Objects.VoucherHeader();

                BAL.VoucherID        = Int32.Parse(txtVoucherNo.Text);
                BAL.VoucherDate      = dtVoucherDate.Value;
                BAL.VoucherType      = getVoucherType();
                BAL.Narration        = txtNarration.Text;
                BAL.PrintVoucherType = cboPrintOnVoucher.Text;

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

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

                if (vOpenMode)
                {
                    objDAL.UpdateRecord(BAL);
                    objDAL.DeleteRecordBody(Int32.Parse(txtVoucherNo.Text), getVoucherType());
                }
                else
                {
                    objDAL.InsertRecord(BAL);
                }

                //Save Detail
                foreach (DataGridViewRow dr in Grid.Rows)
                {
                    if (dr.Cells[0].Value != null)
                    {
                        Objects.VoucherBody objBody = new Objects.VoucherBody();
                        objBody.VoucherID   = Int32.Parse(txtVoucherNo.Text);
                        objBody.VoucherType = getVoucherType();
                        objBody.AccountNo   = dr.Cells["AccountNo"].Value.ToString();
                        objBody.Debit       = decimal.Parse(dr.Cells["Debit"].Value.ToString());
                        objBody.Credit      = decimal.Parse(dr.Cells["Credit"].Value.ToString());
                        objBody.Remarks     = dr.Cells["Remarks"].Value.ToString();

                        objDAL.InsertRecordBody(objBody);
                    }
                }
                Message.ShowMessage(MyMessages.MessageType.SaveRecord);
                PrintVoucher(txtVoucherNo.Text, getVoucherType());

                SetMode(false);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message.ToString(), "Error");
            }
        }