Exemplo n.º 1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ID != 0)
                {
                    if (MessageBox.Show("Do you want to Delete this '" + txtBranchName.Text + "'", "DELETE", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        MASTERBANKBRANCH mb = db.MASTERBANKBRANCHes.Where(x => x.BANKBRANCH_CODE == ID).FirstOrDefault();
                        var OldData         = new JSonHelper().ConvertObjectToJSon(mb);

                        db.MASTERBANKBRANCHes.Remove(mb);
                        db.SaveChanges();

                        AppLib.EventHistory(this.Tag.ToString(), 2, OldData, "", "MASTERBANKBRANCH");
                        MessageBox.Show("Deleted Successfully!", "DELETED");
                        ClearForm();
                    }
                }
                else
                {
                    MessageBox.Show("Please Select Any Bank! (Double Click to Select)");
                }
            }
            catch (Exception ex)
            {
                Nube.ExceptionLogging.SendErrorToText(ex);
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (cmbBankName.Text == "")
                {
                    MessageBox.Show("Enter Bank..", "Information");
                    txtBranchName.Focus();
                }

                else if (txtBranchCode.Text == "")
                {
                    MessageBox.Show("Enter Branchcode..", "Information");
                    txtBranchCode.Focus();
                }
                else if (txtBranchName.Text == "")
                {
                    MessageBox.Show("Enter Branchname..", "Information");
                }
                else
                {
                    if (MessageBox.Show("Do you want to save this record?", "SAVE", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        if (ID != 0)
                        {
                            decimal          id = (decimal)ID;
                            var              s  = cmbBankName.Text.ToString();
                            MASTERBANKBRANCH mb = db.MASTERBANKBRANCHes.Where(x => x.BANKBRANCH_CODE == id).FirstOrDefault();

                            //var OldData = new JSonHelper().ConvertObjectToJSon(mb);

                            mb.BANK_CODE             = Convert.ToDecimal(cmbBankName.SelectedValue);
                            mb.BANKBRANCH_NAME       = txtBranchName.Text;
                            mb.BANKBRANCH_USERCODE   = txtBranchCode.Text;
                            mb.BANKBRANCH_ADDRESS1   = txtAddress1.Text;
                            mb.BANKBRANCH_ADDRESS2   = txtAddress2.Text;
                            mb.BANKBRANCH_ADDRESS3   = txtAddress3.Text;
                            mb.BANKBRANCH_CITY_CODE  = Convert.ToDecimal(cmbCity.SelectedValue);
                            mb.BANKBRANCH_COUNTRY    = (cmbCountry.Text.ToString() == null ? "" : cmbCountry.Text.ToString());
                            mb.BANKBRANCH_EMAIL      = txtEmail.Text;
                            mb.BANKBRANCH_PHONE1     = txtMobile.Text;
                            mb.BANKBRANCH_PHONE2     = txtPhone.Text;
                            mb.BANKBRANCH_STATE_CODE = Convert.ToDecimal(cmbState.SelectedValue);
                            mb.BANKBRANCH_ZIPCODE    = txtPostalCode.Text;
                            mb.NUBE_BRANCH_CODE      = Convert.ToDecimal(cmbNUBEBranch.SelectedValue);
                            mb.HEAD_QUARTERS         = Convert.ToDecimal(ckbHeadOffice.IsChecked);

                            db.SaveChanges();
                            AppLib.lstMASTERBANKBRANCH = db.MASTERBANKBRANCHes.OrderBy(x => x.BANKBRANCH_NAME).ToList();

                            //var NewData = new JSonHelper().ConvertObjectToJSon(mb);
                            //AppLib.EventHistory(this.Tag.ToString(), 1, OldData, NewData, "MASTERBANKBRANCH");

                            MessageBox.Show("Saved Successfully", "Saved");
                            ClearForm();
                        }
                        else
                        {
                            MASTERBANKBRANCH mb = new MASTERBANKBRANCH();
                            mb.BANK_CODE             = Convert.ToDecimal(cmbBankName.SelectedValue);
                            mb.BANKBRANCH_NAME       = txtBranchName.Text;
                            mb.BANKBRANCH_USERCODE   = txtBranchCode.Text;
                            mb.BANKBRANCH_ADDRESS1   = txtAddress1.Text;
                            mb.BANKBRANCH_ADDRESS2   = txtAddress2.Text;
                            mb.BANKBRANCH_ADDRESS3   = txtAddress3.Text;
                            mb.BANKBRANCH_CITY_CODE  = Convert.ToDecimal(cmbCity.SelectedValue);
                            mb.BANKBRANCH_COUNTRY    = (cmbCountry.Text.ToString() == null ? "" : cmbCountry.Text.ToString());
                            mb.BANKBRANCH_EMAIL      = txtEmail.Text;
                            mb.BANKBRANCH_PHONE1     = txtMobile.Text;
                            mb.BANKBRANCH_PHONE2     = txtPhone.Text;
                            mb.BANKBRANCH_STATE_CODE = Convert.ToDecimal(cmbState.SelectedValue);
                            mb.BANKBRANCH_ZIPCODE    = txtPostalCode.Text;
                            mb.NUBE_BRANCH_CODE      = Convert.ToDecimal(cmbNUBEBranch.SelectedValue);
                            mb.HEAD_QUARTERS         = Convert.ToDecimal(ckbHeadOffice.IsChecked);

                            db.MASTERBANKBRANCHes.Add(mb);
                            db.SaveChanges();
                            AppLib.lstMASTERBANKBRANCH = db.MASTERBANKBRANCHes.OrderBy(x => x.BANKBRANCH_NAME).ToList();

                            var NewData = new JSonHelper().ConvertObjectToJSon(mb);
                            AppLib.EventHistory(this.Tag.ToString(), 0, "", NewData, "MASTERBANKBRANCH");

                            MessageBox.Show("Saved Successfully!", "Saved");
                            ClearForm();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Nube.ExceptionLogging.SendErrorToText(ex);
            }
        }