Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                DEWSRMEntities      db                   = new DEWSRMEntities();
                int[]               selRows              = ((GridView)grdInvFixed.MainView).GetSelectedRows();
                DataRowView         oExpenseID           = (DataRowView)(((GridView)grdInvFixed.MainView).GetRow(selRows[0]));
                int                 nID                  = Convert.ToInt32(oExpenseID["ID"]);
                ShareInvestmentHead oShareInvestmentHead = db.ShareInvestmentHeads.FirstOrDefault(p => p.SIHID == nID);

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

                if (MessageBox.Show("Do you want to delete the selected item?", "Delete Setup", MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    db.ShareInvestmentHeads.Attach(oShareInvestmentHead);
                    db.ShareInvestmentHeads.Remove(oShareInvestmentHead);
                    db.SaveChanges();

                    MessageBox.Show("Data Deleted Successfully.", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    RefreshFixedList();
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show("Cannot delete item due to " + Ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                DEWSRMEntities db         = new DEWSRMEntities();
                int[]          selRows    = ((GridView)grdInvFixed.MainView).GetSelectedRows();
                DataRowView    oExpenseID = (DataRowView)(((GridView)grdInvFixed.MainView).GetRow(selRows[0]));

                int nID = Convert.ToInt32(oExpenseID["ID"]);
                ShareInvestmentHead oSIHead = db.ShareInvestmentHeads.FirstOrDefault(p => p.SIHID == nID);

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

                fInvestmentHead frm = new fInvestmentHead();
                frm.ItemChanged = RefreshFixedList;
                frm.ShowDlg(oSIHead, false, 2);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 3
0
 public void ShowDlg(ShareInvestmentHead oShareInvestmentHead, bool IsNew, int nParaentID)
 {
     _IsNew = IsNew;
     _ShareInvestmentHead = oShareInvestmentHead;
     //PopulateInvTypeCbo();
     _ParentId = nParaentID;
     RefreshValue();
     this.ShowDialog();
 }
Ejemplo n.º 4
0
        private void RefreshListLiabilityPay()
        {
            try
            {
                using (DEWSRMEntities db = new DEWSRMEntities())
                {
                    //var _ShareInvesntments = db.ShareInvestments.Where(a => a.TransactionType == (int)EnumTransactionType.Pay);
                    //var _InvesntmentHeads = db.ShareInvestmentHeads.Where(a => a.Type == (int)EnumInvestmentType.Loan || a.Type == (int)EnumInvestmentType.FromOwner || a.Type == (int)EnumInvestmentType.Others);

                    decimal LPAmt = 0;
                    var     _ShareInvesntments = db.ShareInvestments.Where(a => a.TransactionType == (int)EnumTransactionType.Pay &&
                                                                           a.ShareInvestmentHead.ParentId == (int)EnumParentType.Liability);
                    var _InvesntmentHeads = db.ShareInvestmentHeads.Where(a => a.ParentId == (int)EnumParentType.Liability);

                    ShareInvestmentHead oSIHead = null;
                    DataTable           dt      = new DataTable();
                    DataRow             dr      = null;
                    int Count = 0;

                    dt.Columns.Add("ID");
                    dt.Columns.Add("InvHead");
                    dt.Columns.Add("Purpose");
                    dt.Columns.Add("Amount");
                    dt.Columns.Add("EntryDate");

                    if (_ShareInvesntments != null)
                    {
                        Count = 0;
                        foreach (ShareInvestment grd in _ShareInvesntments)
                        {
                            oSIHead = _InvesntmentHeads.FirstOrDefault(s => s.SIHID == grd.SIHID);
                            if (oSIHead != null)//&& oSIHead.Type!=(int)EnumInvestmentType.FixedAsset
                            {
                                dr              = dt.NewRow();
                                dr["ID"]        = grd.SIID;
                                dr["EntryDate"] = grd.EntryDate.ToString("dd MMM yyyy");
                                dr["InvHead"]   = oSIHead.Name;
                                dr["Purpose"]   = grd.Purpose;
                                dr["Amount"]    = grd.Amount;
                                //dr["Type"] = "";//((EnumInvestmentType)Enum.Parse(typeof(EnumInvestmentType), grd.ShareInvestmentHead.Type.ToString())).ToString(); ;
                                dt.Rows.Add(dr);
                                Count++;
                                LPAmt = LPAmt + grd.Amount;
                            }
                        }

                        grdLiabilitiesPay.DataSource = dt;
                        label3.Text = "Total :" + Count.ToString();
                        lblLP.Text  = "T.Amount :" + LPAmt.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void RefreshFAssetList()
        {
            try
            {
                using (DEWSRMEntities db = new DEWSRMEntities())
                {
                    decimal FixedAssetAmt = 0;
                    //var _ShareInvesntments = db.ShareInvestments.Where(a => a.ShareInvestmentHead.Type == (int)EnumInvestmentType.FixedAsset);
                    //var _InvesntmentHeads = db.ShareInvestmentHeads.Where(a => a.Type == (int)EnumInvestmentType.FixedAsset|| a.Type == (int)EnumInvestmentType.FixedAsset);

                    var _ShareInvesntments = db.ShareInvestments.Where(a => a.ShareInvestmentHead.ParentId == (int)EnumParentType.FixedAsset);
                    var _InvesntmentHeads  = db.ShareInvestmentHeads.Where(a => a.ParentId == (int)EnumParentType.FixedAsset);


                    ShareInvestmentHead oSIHead = null;
                    DataTable           dt      = new DataTable();
                    DataRow             dr      = null;

                    dt.Columns.Add("ID");
                    dt.Columns.Add("InvHead");
                    dt.Columns.Add("Purpose");
                    dt.Columns.Add("Amount");
                    dt.Columns.Add("EntryDate");

                    if (_ShareInvesntments != null)
                    {
                        foreach (ShareInvestment grd in _ShareInvesntments)
                        {
                            oSIHead = _InvesntmentHeads.FirstOrDefault(s => s.SIHID == grd.SIHID);

                            dr              = dt.NewRow();
                            dr["ID"]        = grd.SIID;
                            dr["EntryDate"] = grd.EntryDate.ToString("dd MMM yyyy");
                            dr["InvHead"]   = oSIHead.Name;
                            dr["Purpose"]   = grd.Purpose;
                            dr["Amount"]    = grd.Amount;
                            //dr["Type"] = "Fixed Asset";//((EnumInvestmentType)Enum.Parse(typeof(EnumInvestmentType), grd.ShareInvestmentHead.Type.ToString())).ToString(); ;
                            dt.Rows.Add(dr);
                            FixedAssetAmt = FixedAssetAmt + grd.Amount;
                        }

                        grdInvestment.DataSource = dt;
                        lblTotal.Text            = "Total :" + _ShareInvesntments.Count().ToString();
                        lblFA.Text = "T.Amount :" + FixedAssetAmt.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool isNew = false;
                if (!IsValid())
                {
                    return;
                }
                using (DEWSRMEntities db = new DEWSRMEntities())
                {
                    if (_ShareInvestmentHead.SIHID <= 0)
                    {
                        #region Validation Check
                        if (txtName.Text.Length > 0)
                        {
                            ShareInvestmentHead oShareInvestmentHead = (ShareInvestmentHead)(db.ShareInvestmentHeads.FirstOrDefault(o => o.Name.Trim().ToUpper() == txtName.Text.Trim().ToUpper()));
                            if (oShareInvestmentHead != null)
                            {
                                MessageBox.Show("Investment name already Exists.", "Duplicate Invest Item.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                txtName.Focus();
                                return;
                            }
                        }

                        #endregion

                        RefreshObject();
                        _ShareInvestmentHead.SIHID = db.ShareInvestmentHeads.Count() > 0 ? db.ShareInvestmentHeads.Max(obj => obj.SIHID) + 1 : 1;
                        db.ShareInvestmentHeads.Add(_ShareInvestmentHead);
                        isNew = true;
                    }
                    else
                    {
                        _ShareInvestmentHead = db.ShareInvestmentHeads.FirstOrDefault(obj => obj.SIHID == _ShareInvestmentHead.SIHID);
                        RefreshObject();
                    }

                    db.SaveChanges();
                    MessageBox.Show("Data saved successfully.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (!isNew)
                    {
                        if (ItemChanged != null)
                        {
                            ItemChanged();
                        }
                        this.Close();
                    }
                    else
                    {
                        if (ItemChanged != null)
                        {
                            ItemChanged();
                        }
                        _ShareInvestmentHead = new ShareInvestmentHead();
                        RefreshValue();
                        txtCode.Text = GenerateInvestCode();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    MessageBox.Show(ex.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(ex.InnerException.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 7
0
        private void grdItems_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            try
            {
                ShareInvestmentHead oShareHead = null;

                int[]       selRows = ((GridView)grdItems.MainView).GetSelectedRows();
                DataRowView oID     = (DataRowView)(((GridView)grdItems.MainView).GetRow(selRows[0]));
                int         nID     = Convert.ToInt32(oID["ID"]);

                if (nID > 0)
                {
                    if (_ObjectName == "FAsset")
                    {
                        this.Text       = "Fixed Asset";
                        oShareHead      = db.ShareInvestmentHeads.FirstOrDefault(p => p.SIHID == nID);
                        _ctl.SelectedID = oShareHead.SIHID;
                        _ctl.Code       = oShareHead.Code;
                        _ctl.Name       = oShareHead.Name;
                    }
                    else if (_ObjectName == "CAsset")
                    {
                        this.Text       = "Current Asset";
                        oShareHead      = db.ShareInvestmentHeads.FirstOrDefault(p => p.SIHID == nID);
                        _ctl.SelectedID = oShareHead.SIHID;
                        _ctl.Code       = oShareHead.Code;
                        _ctl.Name       = oShareHead.Name;
                    }
                    else if (_ObjectName == "LReceive")
                    {
                        this.Text       = "Liability Receive";
                        oShareHead      = db.ShareInvestmentHeads.FirstOrDefault(p => p.SIHID == nID);
                        _ctl.SelectedID = oShareHead.SIHID;
                        _ctl.Code       = oShareHead.Code;
                        _ctl.Name       = oShareHead.Name;
                    }
                    else if (_ObjectName == "LPay")
                    {
                        this.Text       = "Liability Pay";
                        oShareHead      = db.ShareInvestmentHeads.FirstOrDefault(p => p.SIHID == nID);
                        _ctl.SelectedID = oShareHead.SIHID;
                        _ctl.Code       = oShareHead.Code;
                        _ctl.Name       = oShareHead.Name;
                    }
                    else if (_ObjectName == "Liability")
                    {
                        this.Text       = "Liability";
                        oShareHead      = db.ShareInvestmentHeads.FirstOrDefault(p => p.SIHID == nID);
                        _ctl.SelectedID = oShareHead.SIHID;
                        _ctl.Code       = oShareHead.Code;
                        _ctl.Name       = oShareHead.Name;
                    }
                }
                if (ItemChanged != null)
                {
                    ItemChanged();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 8
0
        private void Refresh()
        {
            try
            {
                using (DEWSRMEntities db = new DEWSRMEntities())
                {
                    if (ObjectName == "Company")
                    {
                        _Supplier = db.Suppliers.FirstOrDefault(o => o.SupplierID == SelectedID);
                        if (_Supplier == null)
                        {
                            _CID = 0;
                        }
                        else
                        {
                            _CID = _Supplier.SupplierID;
                        }

                        if (_Supplier != null)
                        {
                            txtCode.Text = _Supplier.Code;
                            txtName.Text = _Supplier.OwnerName;//_Supplier.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "Customer")
                    {
                        _Customer = db.Customers.FirstOrDefault(o => o.CustomerID == SelectedID);
                        if (_Customer != null)
                        {
                            _CID         = _Customer.CustomerID;
                            txtCode.Text = _Customer.Code;
                            txtName.Text = _Customer.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "Model")
                    {
                        _Model = db.Models.FirstOrDefault(o => o.ModelID == SelectedID);
                        if (_Model != null)
                        {
                            txtCode.Text = _Model.Code;
                            txtName.Text = _Model.Description;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "ReturnProduct")
                    {
                        StockDetail oSD = db.StockDetails.FirstOrDefault(o => o.SDetailID == SelectedID);

                        if (oSD != null)
                        {
                            _Product     = db.Products.FirstOrDefault(o => o.ProductID == oSD.Stock.ProductID);
                            txtCode.Text = _Product.Code;
                            txtName.Text = _Product.ProductName;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "Employee")
                    {
                        _Employee = db.Employees.FirstOrDefault(o => o.EmployeeID == SelectedID);
                        if (_Employee != null)
                        {
                            txtCode.Text = _Employee.Code;
                            txtName.Text = _Employee.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "Product")
                    {
                        _Product = db.Products.FirstOrDefault(o => o.ProductID == SelectedID);
                        if (_Product != null)
                        {
                            txtCode.Text = _Product.Code;
                            txtName.Text = _Product.ProductName;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "OProduct")
                    {
                        _Product = db.Products.FirstOrDefault(o => o.ProductID == SelectedID);
                        if (_Product != null)
                        {
                            txtCode.Text = _Product.Code;
                            txtName.Text = _Product.ProductName;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "SPReport")
                    {
                        _Product = db.Products.FirstOrDefault(o => o.ProductID == SelectedID);
                        if (_Product != null)
                        {
                            txtCode.Text = _Product.Code;
                            txtName.Text = _Product.ProductName;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "CCompany")
                    {
                        _Supplier = db.Suppliers.FirstOrDefault(o => o.SupplierID == SelectedID);
                        if (_Supplier != null)
                        {
                            txtCode.Text = _Supplier.Code;
                            txtName.Text = _Supplier.OwnerName;//_Supplier.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "IncomeOnly")
                    {
                        _ExpenseItem = db.ExpenseItems.FirstOrDefault(o => o.ExpenseItemID == SelectedID);
                        if (_ExpenseItem != null)
                        {
                            txtCode.Text = _ExpenseItem.Code;
                            txtName.Text = _ExpenseItem.Description;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "ExpenseOnly")
                    {
                        _ExpenseItem = db.ExpenseItems.FirstOrDefault(o => o.ExpenseItemID == SelectedID);
                        if (_ExpenseItem != null)
                        {
                            txtCode.Text = _ExpenseItem.Code;
                            txtName.Text = _ExpenseItem.Description;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "CCustomer")
                    {
                        _Customer = db.Customers.FirstOrDefault(o => o.CustomerID == SelectedID);
                        if (_Customer != null)
                        {
                            txtCode.Text = _Customer.Code;
                            txtName.Text = _Customer.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "CreditCustomer")
                    {
                        _Customer = db.Customers.FirstOrDefault(o => o.CustomerID == SelectedID);
                        if (_Customer != null)
                        {
                            txtCode.Text = _Customer.Code;
                            txtName.Text = _Customer.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "SReturn")
                    {
                        StockDetail OSD = db.StockDetails.FirstOrDefault(o => o.SDetailID == SelectedID);

                        if (OSD != null)
                        {
                            _Product = db.Products.FirstOrDefault(o => o.ProductID == OSD.ProductID);
                        }
                        else
                        {
                            _Product = null;
                        }


                        if (_Product != null)
                        {
                            txtCode.Text = _Product.Code;
                            txtName.Text = _Product.ProductName;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "PReturn")
                    {
                        StockDetail OSD = db.StockDetails.FirstOrDefault(o => o.SDetailID == SelectedID);

                        if (OSD != null)
                        {
                            _Product = db.Products.FirstOrDefault(o => o.ProductID == OSD.ProductID);
                        }
                        else
                        {
                            _Product = null;
                        }

                        if (_Product != null)
                        {
                            txtCode.Text = _Product.Code;
                            txtName.Text = _Product.ProductName;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "StockDetail")
                    {
                        StockDetail stockDetail = db.StockDetails.FirstOrDefault(o => o.SDetailID == SelectedID);
                        if (stockDetail != null)
                        {
                            txtName.Text = stockDetail.Product.ProductName;
                            txtCode.Text = stockDetail.Product.Code;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "Category")
                    {
                        _Category = db.Categorys.FirstOrDefault(o => o.CategoryID == SelectedID);
                        if (_Category != null)
                        {
                            txtCode.Text = _Category.Code;
                            txtName.Text = _Category.Description;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "BCompany")
                    {
                        _Company = db.Companies.FirstOrDefault(o => o.CompanyID == SelectedID);
                        if (_Company != null)
                        {
                            txtCode.Text = _Company.Code;
                            txtName.Text = _Company.Description;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "Color")
                    {
                        _Color = db.Colors.FirstOrDefault(o => o.ColorID == SelectedID);
                        if (_Color != null)
                        {
                            txtCode.Text = _Color.Code;
                            txtName.Text = _Color.Description;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "FAsset")
                    {
                        _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID);
                        if (_ShareInvestment != null)
                        {
                            txtCode.Text = _ShareInvestment.Code;
                            txtName.Text = _ShareInvestment.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "CAsset")
                    {
                        _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID);
                        if (_ShareInvestment != null)
                        {
                            txtCode.Text = _ShareInvestment.Code;
                            txtName.Text = _ShareInvestment.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "LReceive")
                    {
                        _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID);
                        if (_ShareInvestment != null)
                        {
                            txtCode.Text = _ShareInvestment.Code;
                            txtName.Text = _ShareInvestment.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "LPay")
                    {
                        _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID);
                        if (_ShareInvestment != null)
                        {
                            txtCode.Text = _ShareInvestment.Code;
                            txtName.Text = _ShareInvestment.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "Liability")
                    {
                        _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID);
                        if (_ShareInvestment != null)
                        {
                            txtCode.Text = _ShareInvestment.Code;
                            txtName.Text = _ShareInvestment.Name;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "Expense")
                    {
                        _ExpenseItem = db.ExpenseItems.FirstOrDefault(o => o.ExpenseItemID == SelectedID);
                        if (_ExpenseItem != null)
                        {
                            txtCode.Text = _ExpenseItem.Code;
                            txtName.Text = _ExpenseItem.Description;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "Godown")
                    {
                        _Godown = db.Godowns.FirstOrDefault(o => o.GodownID == SelectedID);
                        if (_Godown != null)
                        {
                            txtCode.Text = _Godown.GodownCode;
                            txtName.Text = _Godown.GodownName;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                    else if (ObjectName == "MSCustomer")
                    {
                        if (_IDList == null)
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                        else
                        {
                            txtCode.Text = "00000";
                            txtName.Text = "Selected Total:" + _IDList.Count().ToString();
                        }
                    }
                    else if (ObjectName == "Bank")
                    {
                        _BankInfo = db.Banks.FirstOrDefault(o => o.BankID == SelectedID);
                        if (_BankInfo != null)
                        {
                            BankID       = _BankInfo.BankID;
                            txtCode.Text = _BankInfo.Code;
                            txtName.Text = _BankInfo.BankName + "," + _BankInfo.AccountNo;
                        }
                        else
                        {
                            txtCode.Text = "";
                            txtName.Text = "";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }