Пример #1
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            //mClear();
            frmMpoCommManualList objfrm = new frmMpoCommManualList();

            objfrm.onAddAllButtonClicked = new frmMpoCommManualList.AddAllClick(DisplayVoucherList);
            objfrm.lngFormPriv           = lngFormPriv;
            objfrm.Show();
            objfrm.MdiParent = this.MdiParent;
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string    strmsg = "", strkey = "", strBranchID = "", strSQL = "";
            string    connstring = Utility.SQLConnstringComSwitch(strComID);
            double    dblAmount  = 0;
            DataTable dt1        = new DataTable();

            dt1.Columns.Add(new DataColumn("Key"));
            dt1.Columns.Add(new DataColumn("MonthId"));
            dt1.Columns.Add(new DataColumn("BranhID"));
            dt1.Columns.Add(new DataColumn("LedgerName"));
            dt1.Columns.Add(new DataColumn("Headname"));
            dt1.Columns.Add(new DataColumn("Amount"));
            dt1.Columns.Add(new DataColumn("col"));
            dt1.Columns.Add(new DataColumn("row"));
            if (m_action == 1)
            {
                if (chkStatus.Checked)
                {
                    strmsg = Utility.mCheckManual(strComID, strMonthID + "A");
                }
                else
                {
                    strmsg = Utility.mCheckManual(strComID, strMonthID + "I");
                }
                if (strmsg != "")
                {
                    MessageBox.Show(strmsg);
                    return;
                }
            }
            if (Utility.gblnAccessControl)
            {
                if (!Utility.glngGetPriviliges(strComID, Utility.gstrUserName, lngFormPriv, m_action))
                {
                    MessageBox.Show("You have no Permission to Access", "Privileges", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            var strResponseInsert = MessageBox.Show("Do You  want to Save?", "Save Button", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (strResponseInsert == DialogResult.Yes)
            {
                try
                {
                    strBranchID = lstBranch.SelectedValue.ToString();
                    if (chkStatus.Checked)
                    {
                        strkey = uctxtMonthID.Text + strBranchID + "A";
                    }
                    else
                    {
                        strkey = uctxtMonthID.Text + strBranchID + "I";
                    }

                    strmsg = "1";
                    if (strmsg == "1")
                    {
                        for (int intcol = 2; intcol <= DG.Columns.Count - 1; intcol++)
                        {
                            string strHead = DG.Columns[intcol].HeaderText;
                            for (int i = 0; i < DG.Rows.Count; i++)
                            {
                                if (DG[intcol, i].Value != null)
                                {
                                    dblAmount = Convert.ToDouble(DG[intcol, i].Value.ToString());
                                }
                                else
                                {
                                    dblAmount = 0;
                                }
                                dt1.Rows.Add(strkey, uctxtMonthID.Text, strBranchID, DG[1, i].Value.ToString(), strHead, dblAmount, intcol, i);
                                //strmsg = accms.mInsertMpoManual(strComID, strkey, uctxtMonthID.Text, strBranchID, DG[1, i].Value.ToString(), strHead, dblAmount, 0, intcol, i);
                            }
                        }
                        if (dt1.Rows.Count > 0)
                        {
                            //strmsg = objWois.mInsertMpoManual(strComID, strkey, uctxtMonthID.Text, strBranchID, "", "", 0, 1, 0, 0, dt1);

                            using (SqlConnection gcnMain = new SqlConnection(connstring))
                            {
                                if (gcnMain.State == ConnectionState.Open)
                                {
                                    gcnMain.Close();
                                }
                                gcnMain.Open();



                                SqlCommand     cmdInsert = new SqlCommand();
                                SqlTransaction myTrans;
                                myTrans = gcnMain.BeginTransaction();
                                cmdInsert.Connection  = gcnMain;
                                cmdInsert.Transaction = myTrans;

                                strSQL = "DELETE FROM MPO_COMM_MAN_PARENT_CHILD ";
                                strSQL = strSQL + " WHERE ";
                                strSQL = strSQL + " COMM_MANUAL_KEY ='" + strkey.Replace("'", "''") + "' ";
                                cmdInsert.CommandText = strSQL;
                                cmdInsert.ExecuteNonQuery();
                                strSQL = "DELETE FROM MPO_COMM_MAN_PARENT ";
                                strSQL = strSQL + " WHERE ";
                                strSQL = strSQL + " COMM_MANUAL_KEY ='" + strkey.Replace("'", "''") + "' ";
                                cmdInsert.CommandText = strSQL;
                                cmdInsert.ExecuteNonQuery();
                                strSQL = "INSERT INTO MPO_COMM_MAN_PARENT(COMM_MANUAL_KEY,MONTH_ID,BRANCH_ID)";
                                strSQL = strSQL + "VALUES(";
                                strSQL = strSQL + "'" + strkey.Replace("'", "''") + "' ";
                                strSQL = strSQL + ",'" + strMonthID.Replace("'", "''") + "' ";
                                strSQL = strSQL + ",'" + strBranchID.Replace("'", "''") + "' ";
                                strSQL = strSQL + ")";
                                cmdInsert.CommandText = strSQL;
                                cmdInsert.ExecuteNonQuery();
                                if (dt1.Rows.Count > 0)
                                {
                                    progressBar1.Value   = 0;
                                    progressBar1.Maximum = dt1.Rows.Count;
                                    foreach (DataRow dr in dt1.Rows)
                                    {
                                        strSQL = "INSERT INTO MPO_COMM_MAN_PARENT_CHILD(COMM_MANUAL_KEY,LEDGER_NAME,HEAD_NAME,AMOUNT,COLS,ROWPOS)";
                                        strSQL = strSQL + "VALUES(";
                                        strSQL = strSQL + "'" + strkey.Replace("'", "''") + "' ";
                                        strSQL = strSQL + ",'" + dr["LedgerName"].ToString().Replace("'", "''") + "' ";
                                        strSQL = strSQL + ",'" + dr["Headname"].ToString().Replace("'", "''") + "' ";
                                        strSQL = strSQL + "," + Utility.Val(dr["Amount"].ToString()) + " ";
                                        strSQL = strSQL + "," + Utility.Val(dr["col"].ToString()) + " ";
                                        strSQL = strSQL + "," + Utility.Val(dr["row"].ToString()) + " ";
                                        strSQL = strSQL + ")";
                                        cmdInsert.CommandText = strSQL;
                                        cmdInsert.ExecuteNonQuery();
                                        progressBar1.Value += 1;
                                    }
                                }
                                cmdInsert.Transaction.Commit();
                            }
                        }
                        if (strmsg == "1")
                        {
                            if (Utility.gblnAccessControl)
                            {
                                string strAudit = Utility.gblnAuditTrail(Utility.gstrUserName, DateTime.Now.ToString("dd/MM/yyyy"), "Draft MPO Commsiion", strkey,
                                                                         m_action, 0, (int)Utility.MODULE_TYPE.mtACCOUNT, "0001");
                            }
                            MessageBox.Show("Record Saved..");
                            progressBar1.Value = 0;
                            chkStatus.Enabled  = true;
                            if (m_action == 2)
                            {
                                m_action = 1;
                                this.Hide();
                                frmMpoCommManualList objfrm = new frmMpoCommManualList();
                                objfrm.onAddAllButtonClicked = new frmMpoCommManualList.AddAllClick(DisplayVoucherList);
                                objfrm.lngFormPriv           = lngFormPriv;
                                objfrm.Show();
                                objfrm.MdiParent = this.MdiParent;
                            }
                        }
                    }
                }

                catch (Exception EX)
                {
                    MessageBox.Show(EX.ToString());
                }
            }
        }