//private void grfDept_AfterRowColChange(object sender, C1.Win.C1FlexGrid.RangeEventArgs e)
        //{


        //}
        private void ContextMenu_appv(object sender, System.EventArgs e)
        {
            if (grfExpn.Row == null)
            {
                return;
            }
            if (grfExpn.Row < 0)
            {
                return;
            }

            String deptId = "";

            xC.drawID = grfExpn[grfExpn.Row, cola] != null ? grfExpn[grfExpn.Row, cola].ToString() : "";
            ExpensesDraw   expn = new ExpensesDraw();
            FrmExpenseDraw frm;

            expn = xC.accDB.expndDB.selectByPk1(xC.drawID);
            if (expn.status_pay_type.Equals("1"))
            {
                frm = new FrmExpenseDraw(xC, xC.drawID, FrmExpenseDraw.flagForm2.Cash, FrmExpenseDraw.flagAction.appv);
            }
            else
            {
                frm = new FrmExpenseDraw(xC, xC.drawID, FrmExpenseDraw.flagForm2.Cheque, FrmExpenseDraw.flagAction.appv);
            }
            //frm.drawId = xC.drawID;
            //frm.flagForm = "appv";
            frm.WindowState   = FormWindowState.Normal;
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog(this);
        }
        //private void grfDept_AfterRowColChange(object sender, C1.Win.C1FlexGrid.RangeEventArgs e)
        //{

        //}
        private void ContextMenu_edit(object sender, System.EventArgs e)
        {
            if (grfExpn.Row == null)
            {
                return;
            }
            if (grfExpn.Row < 0)
            {
                return;
            }
            Row row = grfExpn.Rows[grfExpn.Row];

            xC.drawID = grfExpn[grfExpn.Row, cola] != null ? grfExpn[grfExpn.Row, cola].ToString() : "";
            FrmExpenseDraw frm = new FrmExpenseDraw(xC, xC.drawID, (FrmExpenseDraw.flagForm2)flagfom2, FrmExpenseDraw.flagAction.draw);
            //frm.drawId = xC.drawID;
            //frm.flagForm = "view";
            //frm.ShowDialog(this);
            String txt = "";

            if (flagfom2 == flagForm2.Cash)
            {
                txt = "ใบเบิกเงิน จ่ายพนักงาน(เงินสด) ป้อนใหม่";
            }
            else
            {
                txt = "ใบเบิกเงิน จ่ายพนักงาน(cheque) ป้อนใหม่";
            }
            frm.FormBorderStyle = FormBorderStyle.None;
            menu.AddNewTab(frm, txt + xC.drawID);
        }
        private void BtnDNew_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            xC.userIderc = cboStaff.SelectedItem != null ? ((ComboBoxItem)(cboStaff.SelectedItem)).Value : "";
            FrmExpenseDraw frm = new FrmExpenseDraw(xC, "", FrmExpenseDraw.flagForm2.Cash, FrmExpenseDraw.flagAction.autoappv);

            frm.StartPosition = FormStartPosition.CenterParent;
            frm.WindowState   = FormWindowState.Normal;
            frm.ShowDialog(this);
            setGrfEcc(cboStaff.SelectedItem != null ? ((ComboBoxItem)(cboStaff.SelectedItem)).Value : "");
        }
        private void ContextMenu_GrfEcc_edit(object sender, System.EventArgs e)
        {
            if (grfEcc[grfEcc.Row, colEccId] == null)
            {
                return;
            }
            if (grfEcc.Row < 0)
            {
                return;
            }
            String eccid = "", flag = "";

            eccid = grfEcc[grfEcc.Row, colEccId].ToString();
            flag  = grfEcc[grfEcc.Row, colflag].ToString();
            if (eccid.Equals(""))
            {
                return;
            }


            if (flag.Equals("ecc"))
            {
                //int row = 0;
                //row = grfEcc != null ? grfEcc.Rows.Count : 0;
                FrmExpenseClearCash frm = new FrmExpenseClearCash(xC, eccid, "", "", "", "");
                frm.WindowState   = FormWindowState.Normal;
                frm.StartPosition = FormStartPosition.CenterParent;
                frm.ShowDialog(this);
            }
            else if (flag.Equals("erf"))
            {
                FrmExpenseClearCashRefund frm = new FrmExpenseClearCashRefund(xC, cboStaff.SelectedItem != null ? ((ComboBoxItem)(cboStaff.SelectedItem)).Value : "", eccid);
                frm.WindowState   = FormWindowState.Normal;
                frm.StartPosition = FormStartPosition.CenterParent;
                frm.ShowDialog(this);
            }
            else if (flag.Equals("dd"))
            {
                xC.userIderc = cboStaff.SelectedItem != null ? ((ComboBoxItem)(cboStaff.SelectedItem)).Value : "";
                FrmExpenseDraw frm = new FrmExpenseDraw(xC, eccid, FrmExpenseDraw.flagForm2.Cash, FrmExpenseDraw.flagAction.autoappv);
                frm.StartPosition = FormStartPosition.CenterParent;
                frm.WindowState   = FormWindowState.Normal;
                frm.ShowDialog(this);
            }
            setGrfEcc(cboStaff.SelectedItem != null ? ((ComboBoxItem)(cboStaff.SelectedItem)).Value : "");
        }
        private void BtnNew_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            xC.drawID = "";
            FrmExpenseDraw frm = new FrmExpenseDraw(xC, "", (FrmExpenseDraw.flagForm2)flagfom2, FrmExpenseDraw.flagAction.draw);
            //frm.drawId = "";
            //frm.flagForm = "new";
            //frm.ShowDialog(this);
            //frm.WindowState = FormWindowState.Normal;
            //frm.StartPosition = FormStartPosition.CenterScreen;
            String txt = "";

            if (flagfom2 == flagForm2.Cash)
            {
                txt = "ใบเบิกเงิน จ่ายพนักงาน(เงินสด) ป้อนใหม่";
            }
            else
            {
                txt = "ใบเบิกเงิน จ่ายพนักงาน(cheque) ป้อนใหม่";
            }
            frm.FormBorderStyle = FormBorderStyle.None;
            menu.AddNewTab(frm, txt);
        }