Пример #1
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     try
     {
         fExpenseItem frm = new fExpenseItem();
         frm.ItemChanged = RefreshList;
         frm.ShowDlg(new ExpenseItem(), true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                DEWSRMEntities db         = new DEWSRMEntities();
                int[]          selRows    = ((GridView)grdExpens.MainView).GetSelectedRows();
                DataRowView    oExpenseID = (DataRowView)(((GridView)grdExpens.MainView).GetRow(selRows[0]));

                int         nExpenseID = Convert.ToInt32(oExpenseID["ExpenseItemID"]);
                ExpenseItem oExpense   = db.ExpenseItems.FirstOrDefault(p => p.ExpenseItemID == nExpenseID);

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

                fExpenseItem frm = new fExpenseItem();
                frm.ItemChanged = RefreshList;
                frm.ShowDlg(oExpense, false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //try
            //{
            //    if (lsvExpenseItem.SelectedItems.Count <= 0)
            //    {
            //        MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //        return;
            //    }
            //    ExpenseItem oExpenseItem = null;
            //    fExpenseItem frm = new fExpenseItem();

            //    if (lsvExpenseItem.SelectedItems != null && lsvExpenseItem.SelectedItems.Count > 0)
            //    {
            //        oExpenseItem = (ExpenseItem)lsvExpenseItem.SelectedItems[0].Tag;
            //    }
            //    frm.ItemChanged = RefreshList;
            //    frm.ShowDlg(oExpenseItem,false);

            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
        }
Пример #3
0
        private void btnNewCompany_Click(object sender, EventArgs e)
        {
            try
            {
                ForExpense = true;
                fExpenseItem frm = new fExpenseItem();
                frm.ShowDlg(new ExpenseItem(), true);

                if (ForExpense)
                {
                    db = new DEWSRMEntities();
                    List <ExpenseItem> oExpenseList = db.ExpenseItems.ToList();
                    ctlExpense.SelectedID = oExpenseList[oExpenseList.Count - 1].ExpenseItemID;
                    ForExpense            = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }