Пример #1
0
        void frmVoucher_Edit_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.F12:
            {
                if (e.Control)
                {
                    Epoint.Systems.Customizes.frmView frm = new Epoint.Systems.Customizes.frmView();
                    frm.Text = "Detail";

                    SplitContainer splc = new SplitContainer();
                    splc.Orientation      = Orientation.Horizontal;
                    splc.SplitterDistance = splc.Height / 3;
                    splc.Dock             = DockStyle.Fill;

                    DataGridView dgvPh = new DataGridView();
                    dgvPh.Dock               = DockStyle.Fill;
                    dgvPh.DataSource         = dtEditPh;
                    dgvPh.BackgroundColor    = Color.White;
                    dgvPh.AllowUserToAddRows = false;
                    splc.Panel1.Controls.Add(dgvPh);

                    DataGridView dgvCt = new DataGridView();
                    dgvCt.Dock               = DockStyle.Fill;
                    dgvCt.DataSource         = dtEditCt;
                    dgvCt.BackgroundColor    = Color.White;
                    dgvCt.AllowUserToAddRows = false;
                    splc.Panel2.Controls.Add(dgvCt);

                    frm.Controls.Add(splc);
                    frm.WindowState = FormWindowState.Maximized;
                    frm.Show();
                }
                break;
            }

            case Keys.F6:
                if ((e.Alt || e.Control) || e.Shift)
                {
                    if ((!e.Alt && e.Control) && !e.Shift)
                    {
                        Voucher.CopyNewRow(this);
                    }
                    break;
                }
                Voucher.AddRow(this);
                break;

            case Keys.S:
                if (e.Control)
                {
                    if (this.Save())
                    {
                        isAccept = true;

                        if ((enuNew_Edit == enuEdit.New || enuNew_Edit == enuEdit.Copy) && drDmCt.Table.Columns.Contains("Auto_New_Voucher") && (bool)drDmCt["Auto_New_Voucher"])
                        {
                            this.Load(enuEdit.New, drEdit, dsVoucher);
                        }
                        else
                        {
                            this.Close();
                        }
                        //base.ShowSuccessMessage("Thành công !");
                        //MessageBox.Show("Thành công !");
                    }
                }
                break;
            }
        }
Пример #2
0
        private bool CellKeyEnter()
        {        //Ham thuc hien phim Enter: true: thuc hien thanh cong, false: khong thuc hien duoc
            if (dgvEditCt1.CurrentCell == null)
            {
                return(false);
            }

            DataGridViewCell dgvCell          = dgvEditCt1.CurrentCell;
            string           strCurrentColumn = dgvCell.OwningColumn.Name.ToUpper();

            #region Enter tai TEN_VT
            if (Common.Inlist(strCurrentColumn, "TEN_VT"))
            {
                drCurrent = ((DataRowView)bdsEditCt.Current).Row;

                if (drCurrent["Ma_Vt"] == DBNull.Value || (string)drCurrent["Ma_Vt"] == string.Empty)
                {
                    bool bIsCurrentLastRow = dgvEditCt1.bIsCurrentLastRow;

                    bdsEditCt.RemoveCurrent();
                    dtEditCt.AcceptChanges();

                    if (bIsCurrentLastRow)
                    {
                        this.SelectNextControl(dgvEditCt1, true, true, true, true);
                    }

                    return(true);
                }

                return(false);
            }
            #endregion

            #region Enter tai TIEN_NT9
            if (Common.Inlist(strCurrentColumn, "TIEN_NT9"))
            {
                if (txtMa_Tte.Text.Trim() == Element.sysMa_Tte)
                {
                    // Cap nhat tien TIEN_NT9 truoc khi xuong dong
                    double dbTien_Nt9 = 0;
                    if (double.TryParse(dgvEditCt1.CurrentCell.FormattedValue.ToString().Trim(), out dbTien_Nt9))
                    {
                        dgvEditCt1.CancelEdit();
                        drCurrent             = ((DataRowView)bdsEditCt.Current).Row;
                        drCurrent["TIEN_NT9"] = dbTien_Nt9;
                        Voucher.Calc_So_Luong(drCurrent);
                        Voucher.Update_TTien(this);
                    }

                    if (dgvEditCt1.bIsCurrentLastRow)
                    {
                        if (!Voucher.AddRow(this))
                        {
                            this.SelectNextControl(dgvEditCt1, true, true, true, true);
                        }
                        else
                        {
                            dgvEditCt1.FocusNextFirstCell();
                            return(true);
                        }
                    }
                    else
                    {
                        dgvEditCt1.FocusNextFirstCell();
                    }
                }
                return(false);
            }

            #endregion

            #region Enter TIEN
            if (Common.Inlist(strCurrentColumn, "TIEN"))
            {
                if (dgvEditCt1.bIsCurrentLastRow)
                {
                    // Cap nhat Tien truoc khi xuống dòng
                    double dbTien = 0;
                    if (double.TryParse(dgvEditCt1.CurrentCell.FormattedValue.ToString().Trim(), out dbTien))
                    {
                        dgvEditCt1.CancelEdit();
                        drCurrent         = ((DataRowView)bdsEditCt.Current).Row;
                        drCurrent["TIEN"] = dbTien;
                        Voucher.Calc_So_Luong(drCurrent);
                        Voucher.Update_TTien(this);
                    }

                    if (!Voucher.AddRow(this))
                    {
                        return(false);
                    }
                    else
                    {
                        dgvEditCt1.FocusNextFirstCell();
                    }


                    return(true);
                }

                return(false);
            }
            #endregion

            return(false);
        }