Esempio n. 1
0
        private bool IsBankNameExist(LenderBanks lenderBank)
        {
            try
            {
                DataTable dtList = GetAll();
                var       rows   = dtList.AsEnumerable().Where(x => ((string)x["BankName"]).ToString() == lenderBank.BankName);
                DataTable dt     = rows.Any() ? rows.CopyToDataTable() : dtList.Clone();

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 protected void btnDelete_Command(object sender, CommandEventArgs e)
 {
     try
     {
         string id = Convert.ToString(e.CommandArgument);
         if (!string.IsNullOrEmpty(id))
         {
             LenderBankBLL lenderBankBLL = new LenderBankBLL();
             LenderBanks   lenderBank    = new LenderBanks();
             lenderBank.LenderBankId = Convert.ToInt32(QuaintSecurityManager.Decrypt(id));
             if (lenderBank.LenderBankId > 0)
             {
                 if (lenderBankBLL.Delete(lenderBank))
                 {
                     Alert(AlertType.Success, "Deleted successfully.");
                     LoadList();
                 }
                 else
                 {
                     Alert(AlertType.Error, "Failed to delete.");
                 }
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to delete.");
     }
 }
Esempio n. 3
0
        public bool Delete(LenderBanks lenderBank)
        {
            QuaintDatabaseManager db = new QuaintDatabaseManager(true);

            try
            {
                bool flag = false;
                db.AddParameters("LenderBankId", lenderBank.LenderBankId);
                int affectedRows = db.ExecuteNonQuery("Delete_LenderBank", true);

                if (affectedRows > 0)
                {
                    flag = true;
                }

                return(flag);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Disconnect();
            }
        }
        protected void btnActiveOrDeactive_Command(object sender, CommandEventArgs e)
        {
            try
            {
                string id = Convert.ToString(e.CommandArgument);
                if (!string.IsNullOrEmpty(id))
                {
                    LenderBankBLL lenderBankBLL = new LenderBankBLL();
                    DataTable     dt            = lenderBankBLL.GetById(Convert.ToInt32(QuaintSecurityManager.Decrypt(id)));
                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            string      actionStatus = "Updated";
                            LenderBanks lenderBank   = new LenderBanks();
                            lenderBank.LenderBankId   = Convert.ToInt32(Convert.ToString(dt.Rows[0]["LenderBankId"]));
                            lenderBank.LenderBankCode = Convert.ToString(dt.Rows[0]["LenderBankCode"]);
                            lenderBank.BankName       = Convert.ToString(dt.Rows[0]["BankName"]);
                            lenderBank.Url            = Convert.ToString(dt.Rows[0]["Url"]);
                            lenderBank.Description    = Convert.ToString(dt.Rows[0]["Description"]);
                            lenderBank.IsActive       = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                            lenderBank.CountryId      = Convert.ToInt32(Convert.ToString(dt.Rows[0]["CountryId"]));
                            lenderBank.CreatedDate    = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                            lenderBank.CreatedBy      = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                            lenderBank.CreatedFrom    = Convert.ToString(dt.Rows[0]["CreatedFrom"]);

                            lenderBank.UpdatedDate = DateTime.Now;
                            lenderBank.UpdatedBy   = UserInfo;
                            lenderBank.UpdatedFrom = StationInfo;

                            if (lenderBank.IsActive)
                            {
                                lenderBank.IsActive = false;
                                actionStatus        = "Deactivated";
                            }
                            else
                            {
                                lenderBank.IsActive = true;
                                actionStatus        = "Activated";
                            }

                            if (lenderBankBLL.Update(lenderBank))
                            {
                                Alert(AlertType.Success, actionStatus + " successfully.");
                                LoadList();
                            }
                            else
                            {
                                Alert(AlertType.Error, "Failed to update.");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Alert(AlertType.Error, "Failed to process.");
            }
        }
Esempio n. 5
0
 public bool Delete(LenderBanks lenderBank)
 {
     try
     {
         LenderBankDAL lenderBankDAL = new LenderBankDAL();
         return(lenderBankDAL.Delete(lenderBank));
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 6
0
        public bool Save(LenderBanks lenderBank)
        {
            try
            {
                LenderBankDAL lenderBankDAL = new LenderBankDAL();

                if (IsBankNameExist(lenderBank))
                {
                    throw new Exception("Bank name already exist.");
                }
                else
                {
                    return(lenderBankDAL.Save(lenderBank));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 7
0
        public bool Update(LenderBanks lenderBank)
        {
            QuaintDatabaseManager db = new QuaintDatabaseManager(true);

            try
            {
                bool flag = false;
                db.AddParameters("LenderBankId", lenderBank.LenderBankId);
                db.AddParameters("LenderBankCode", lenderBank.LenderBankCode);
                db.AddParameters("BankName", lenderBank.BankName);
                db.AddParameters("Url", lenderBank.Url);
                db.AddParameters("Description", lenderBank.Description);
                db.AddParameters("IsActive", lenderBank.IsActive);
                db.AddParameters("CreatedDate", ((lenderBank.CreatedDate == null) ? lenderBank.CreatedDate : lenderBank.CreatedDate.Value));
                db.AddParameters("CreatedBy", lenderBank.CreatedBy);
                db.AddParameters("CreatedFrom", lenderBank.CreatedFrom);
                db.AddParameters("UpdatedDate", ((lenderBank.UpdatedDate == null) ? lenderBank.UpdatedDate : lenderBank.UpdatedDate.Value));
                db.AddParameters("UpdatedBy", lenderBank.UpdatedBy);
                db.AddParameters("UpdatedFrom", lenderBank.UpdatedFrom);
                db.AddParameters("CountryId", lenderBank.CountryId);
                int affectedRows = db.ExecuteNonQuery("Update_LenderBank", true);

                if (affectedRows > 0)
                {
                    flag = true;
                }

                return(flag);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Disconnect();
            }
        }
        private void SaveAndUpdate()
        {
            try
            {
                if (string.IsNullOrEmpty(txtBankName.Text))
                {
                    Alert(AlertType.Warning, "Enter bank name.");
                    txtBankName.Focus();
                }
                else if (ddlCountry.SelectedIndex < 1)
                {
                    Alert(AlertType.Warning, "Select country");
                    ddlCountry.Focus();
                }
                else
                {
                    string bankName    = Convert.ToString(txtBankName.Text);
                    string url         = Convert.ToString(txtUrl.Text);
                    string description = Convert.ToString(txtDescription.Text);
                    int    countryId   = Convert.ToInt32(Convert.ToString(ddlCountry.SelectedValue));

                    LenderBankBLL lenderBankBLL = new LenderBankBLL();
                    if (this.ModelId > 0)
                    {
                        DataTable   dt         = lenderBankBLL.GetById(this.ModelId);
                        LenderBanks lenderBank = new LenderBanks();
                        lenderBank.LenderBankId   = Convert.ToInt32(Convert.ToString(dt.Rows[0]["LenderBankId"]));
                        lenderBank.LenderBankCode = Convert.ToString(dt.Rows[0]["LenderBankCode"]);
                        lenderBank.BankName       = Convert.ToString(dt.Rows[0]["BankName"]);
                        lenderBank.Url            = Convert.ToString(dt.Rows[0]["Url"]);
                        lenderBank.Description    = Convert.ToString(dt.Rows[0]["Description"]);
                        lenderBank.IsActive       = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                        lenderBank.CountryId      = Convert.ToInt32(Convert.ToString(dt.Rows[0]["CountryId"]));
                        lenderBank.CreatedDate    = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                        lenderBank.CreatedBy      = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                        lenderBank.CreatedFrom    = Convert.ToString(dt.Rows[0]["CreatedFrom"]);

                        lenderBank.BankName    = bankName.Trim();
                        lenderBank.Url         = url;
                        lenderBank.Description = description;
                        lenderBank.CountryId   = countryId;

                        lenderBank.UpdatedDate = DateTime.Now;
                        lenderBank.UpdatedBy   = this.UserInfo;
                        lenderBank.UpdatedFrom = this.StationInfo;

                        if (lenderBankBLL.Update(lenderBank))
                        {
                            this.MultiEntryDisallow = true;
                            Alert(AlertType.Success, "Updated successfully.");
                            ClearFields();
                        }
                        else
                        {
                            Alert(AlertType.Error, "Failed to update.");
                        }
                    }
                    else
                    {
                        LenderBanks lenderBank = new LenderBanks();
                        lenderBank.LenderBankCode = this.ModelCode;
                        lenderBank.BankName       = bankName.Trim();
                        lenderBank.Url            = url;
                        lenderBank.Description    = description;
                        lenderBank.CountryId      = countryId;
                        lenderBank.IsActive       = true;
                        lenderBank.CreatedDate    = DateTime.Now;
                        lenderBank.CreatedBy      = this.UserInfo;
                        lenderBank.CreatedFrom    = this.StationInfo;

                        if (lenderBankBLL.Save(lenderBank))
                        {
                            Alert(AlertType.Success, "Saved successfully.");
                            ClearFields();
                            GenerateCode();
                        }
                        else
                        {
                            Alert(AlertType.Error, "Failed to save.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Alert(AlertType.Error, ex.Message.ToString());
            }
        }