Ejemplo n.º 1
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     try
     {
         fDamageProduct frm = new fDamageProduct();
         frm.ItemChanged = RefreshList;
         frm.ShowDlg(new DamageProduct());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                DEWSRMEntities db      = new DEWSRMEntities();
                int[]          selRows = ((GridView)grdDProducts.MainView).GetSelectedRows();
                DataRowView    oDID    = (DataRowView)(((GridView)grdDProducts.MainView).GetRow(selRows[0]));
                DataRowView    oEDate  = (DataRowView)(((GridView)grdDProducts.MainView).GetRow(selRows[0]));

                int      nDPID  = Convert.ToInt32(oDID["ID"]);
                DateTime dEDate = Convert.ToDateTime(oEDate["EDate"]);

                DamageProduct oDProduct = db.DamageProducts.FirstOrDefault(p => p.DamageProID == nDPID);

                if (oDProduct == null)
                {
                    MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (Global.CurrentUser.ISEditable == 1)
                {
                    if (dEDate < DateTime.Today)
                    {
                        MessageBox.Show("This damage order can't be editable, Please contact BD Team", "Unauthorized Access", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }

                fDamageProduct frm = new fDamageProduct();
                frm.ItemChanged = RefreshList;
                frm.ShowDlg(oDProduct);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }