Esempio n. 1
0
 private void ListAccountDayBookCode()
 {
     try
     {
         grdList.Rows.Clear();
         AccountDayBookCodeDB  ADBdb   = new AccountDayBookCodeDB();
         List <accountdaybook> ADBList = ADBdb.getAccountDayBookDetail();
         foreach (accountdaybook adb in ADBList)
         {
             grdList.Rows.Add(adb.AccountCode, adb.Name, adb.BookType,
                              getStatusString(adb.status), adb.CreateTime, adb.CreateUser);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
     }
     //enableBottomButtons();
     setButtonVisibility("init");
     pnlAccDayBookCode.Visible = true;
 }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Boolean status = true;

            try
            {
                accountdaybook       adb   = new accountdaybook();
                AccountDayBookCodeDB adbDB = new AccountDayBookCodeDB();
                //adb.BookType = cmbBookType.SelectedItem.ToString().Substring(0, cmbBookType.SelectedItem.ToString().IndexOf("-"));
                adb.BookType    = ((Structures.ComboBoxItem)cmbBookType.SelectedItem).HiddenValue;
                adb.AccountCode = txtAccCode.Text.Substring(0, txtAccCode.Text.IndexOf('-'));
                adb.status      = getStatusCode(cmbBookStatus.SelectedItem.ToString());
                System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button;
                string btnText = btn.Text;
                btnText = btnSave.Text;

                if (btnText.Equals("Update"))
                {
                    if (adbDB.validateACcountDayBookDetail(adb))
                    {
                        if (adbDB.updateAccountDayBookDetail(adb))
                        {
                            MessageBox.Show("Book Type updated");
                            closeAllPanels();
                            ListAccountDayBookCode();
                        }
                        else
                        {
                            status = false;
                            MessageBox.Show("Failed to update Book Type");
                        }
                    }
                    else
                    {
                        status = false;
                        MessageBox.Show("Validation Failed");
                    }
                }
                else if (btnText.Equals("Save"))
                {
                    if (adbDB.validateACcountDayBookDetail(adb))
                    {
                        if (adbDB.insertAccountDayBookDetail(adb))
                        {
                            MessageBox.Show("Book Type added");
                            closeAllPanels();
                            ListAccountDayBookCode();
                        }
                        else
                        {
                            status = false;
                            MessageBox.Show("Failed to insert Book Type");
                            //return;
                        }
                    }
                    else
                    {
                        status = false;
                        MessageBox.Show(" Validation failed");
                    }
                }
            }
            catch (Exception ex)
            {
                status = false;
                MessageBox.Show("Failed Adding / Editing User Data");
            }
            if (status)
            {
                setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save
            }
        }