Exemple #1
0
        public ActionResult Create()
        {
            ONhaCungCap data = new ONhaCungCap();

            data.TrangThai = false;

            return(View("Update", data));
        }
Exemple #2
0
        public void Add(ONhaCungCap item)
        {
            conn.connect();
            var comm = new SqlCommand("NCC_Add", conn.db);

            comm.CommandType = CommandType.StoredProcedure;

            comm.Parameters.Add("@TenNCC", SqlDbType.NVarChar).Value = item.TenNCC;
            comm.Parameters.Add(new SqlParameter("@DiaChi", item.DiaChi ?? (object)DBNull.Value));
            comm.Parameters.Add(new SqlParameter("@SDT", item.SDT ?? (object)DBNull.Value));
            comm.Parameters.Add(new SqlParameter("@IsActive", item.TrangThai ?? (object)DBNull.Value));
            comm.ExecuteNonQuery();
            conn.Close();
        }
Exemple #3
0
        public ONhaCungCap Get(int id)
        {
            conn.connect();
            var comm = new SqlCommand("NCC_Get", conn.db);

            comm.CommandType = CommandType.StoredProcedure;
            comm.Parameters.Add("@MaNCC", SqlDbType.Int).Value = id;

            DataTable   dt  = new DataTable();
            ONhaCungCap NCC = new ONhaCungCap();

            dt.Load(comm.ExecuteReader());
            NCC = Help.DAL.ConvertDataTable <ONhaCungCap>(dt).FirstOrDefault();

            return(NCC);
        }
Exemple #4
0
        public ActionResult Create(ONhaCungCap model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    nccService.Add(model);
                    return(RedirectToAction("Search", "QuanLyNCC"));
                }
                catch (Exception e)
                {
                }
            }

            ViewBag.IsEdit = true;
            return(View("Update", model));
        }
Exemple #5
0
        public ActionResult Update(ONhaCungCap model)
        {
            if (ModelState.IsValid)
            {
                var pro = nccService.Get(model.MaNCC);
                if (pro != null)
                {
                    try
                    {
                        nccService.Update(model);
                        return(RedirectToAction("Search", "QuanLyNCC"));
                    }
                    catch (Exception e)
                    {
                    }
                }
            }

            ViewBag.IsEdit = true;
            return(View(model));
        }