Пример #1
0
        public ActionResult AddBranch(BranchDetails model)
        {
            if (!ModelState.IsValid)
                return View(model);

            AdminDAL obj = new AdminDAL();

            if (!obj.IsUniqueBranchLogInID(model.BranchLogInID))
            {
                ModelState.AddModelError("", "Login ID is alreay taken.");
                return View(model);
            }
            obj.AddBranch(model);
            return View("Dashboard");
        }
Пример #2
0
        public bool AddBranch(BranchDetails bd)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Database1ConnectionString"].ToString());
            CommonDAL commonDALObj = new CommonDAL();
            SqlCommand cmd = new SqlCommand("SELECT MAX(BranchCode) FROM Branch ", connection);
            connection.Open();

            SqlDataReader reader = cmd.ExecuteReader();
            reader.Read();

            if (!reader.IsDBNull(0))
            {

                bd.BranchCode = Convert.ToInt64(reader[0]) + 1;
            }
            else
                bd.BranchCode = 1;

            reader.Close();

            cmd.CommandText = String.Format("SELECT MAX(Id) FROM UserRoles ");

            reader = cmd.ExecuteReader();
            reader.Read();
            int id = Convert.ToInt16(reader[0]) + 1;

            connection.Close();

            SqlConnection cn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["Database1ConnectionString"].ToString());
            string command = String.Format("INSERT INTO Branch VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", bd.BranchCode, bd.BranchName, bd.CityName, bd.Address, bd.ContactNumber, bd.BankerName, bd.BranchLogInID,commonDALObj.GetHashedText(bd.BranchLogInPassword), bd.Email);

            cn2.Open();

            SqlCommand cmd2 = new SqlCommand(command,cn2);
            int res = cmd2.ExecuteNonQuery();

            SqlCommand cmd3 = new SqlCommand(String.Format("INSERT INTO UserRoles VALUES('{0}','{1}', '{2}', '{3}','{4}','{5}', 'A')", id, bd.BranchLogInID, commonDALObj.GetHashedText(bd.BranchLogInPassword), "Banker",DateTime.Now.ToString(),"0"), cn2);
            cmd3.ExecuteNonQuery();

            cn2.Close();

            if (res == 0)
                return false;
            else
                return true;
        }
Пример #3
0
        public bool UpdateBranchDetails(BranchDetails bd)
        {
            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Database1ConnectionString"].ToString());
            string command = String.Format("UPDATE Branch SET Address = '{0}', ContactNumber = '{1}', Email = '{2}', BranchPassword = '******' WHERE BranchCode = '{4}'",bd.Address,bd.ContactNumber,bd.Email,bd.BranchLogInPassword,bd.BranchCode) ;

            // update password in UserProfile
            cn.Open();

            SqlCommand cmd2 = new SqlCommand(command, cn);
            int res = cmd2.ExecuteNonQuery();

            cn.Close();

            if (res == 0)
                return false;
            else
                return true;
        }
Пример #4
0
        public BranchDetails GetBranchDetails(long BranchCode)
        {
            BranchDetails bd = new BranchDetails();

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Database1ConnectionString"].ToString()))
            {
                SqlCommand command = new SqlCommand("SELECT * FROM Branch WHERE BranchCode = '{0}' " + BranchCode, connection);
                connection.Open();

                SqlDataReader rd = command.ExecuteReader();

                // Call Read before accessing data.
                if (rd.HasRows)
                {
                    rd.Read();
                    bd.BranchCode = Convert.ToInt64(rd[0]);
                    bd.BranchName = rd[1].ToString();
                    bd.CityName = rd[2].ToString();
                    bd.Address = rd[3].ToString();
                    bd.ContactNumber = rd[4].ToString();
                    bd.BankerName = rd[5].ToString();
                    bd.BranchLogInID = rd[6].ToString();
                    bd.BranchLogInPassword = rd[7].ToString();
                    bd.Email = rd[8].ToString();
                }

                else
                    System.Windows.Forms.MessageBox.Show("Branch Details Read Failed");

                rd.Close();

            }

            return bd;
        }