Пример #1
0
        protected void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtDiaChiNhaCungCap.Text.Length > 0 && txtEmail.Text.Length > 0 && txtSoDienThoai.Text.Length > 0 && txtTenNhaCungCap.Text.Length > 0)
                {
                    tbl_Supplier supplier = db.tbl_Supplier.Find(int.Parse(txtMaNhaCungCap.Text));
                    supplier.Supplier_Name = txtTenNhaCungCap.Text;
                    supplier.Phone         = Int32.Parse(txtSoDienThoai.Text);
                    supplier.Email         = txtEmail.Text;
                    supplier.Address       = txtDiaChiNhaCungCap.Text;

                    db.SaveChanges();
                    load();
                    lbThongBao.Text      = "Bạn đã sửa thành công";
                    lbThongBao.ForeColor = System.Drawing.Color.Green;
                    reset();
                }
                else
                {
                    lbThongBao.Text      = "Bạn chưa chọn nhà cung cấp cần sửa";
                    lbThongBao.ForeColor = System.Drawing.Color.Red;
                }
            }
            catch (Exception ex)
            {
                lbThongBao.Text      = "Đã có lỗi xảy ra. Vui lòng thử lại sau.";
                lbThongBao.ForeColor = System.Drawing.Color.Red;
            }
        }
Пример #2
0
 public static string Update(int ID, string SupplierName, string SupplierDescription, string SupplierPhone, string SupplierAddress,
                             string SupplierEmail, bool IsHidden, DateTime ModifiedDate, string ModifiedBy)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_Supplier ui = dbe.tbl_Supplier.Where(a => a.ID == ID).SingleOrDefault();
         if (ui != null)
         {
             ui.SupplierName        = SupplierName;
             ui.SupplierDescription = SupplierDescription;
             ui.SupplierPhone       = SupplierPhone;
             ui.SupplierAddress     = SupplierAddress;
             ui.SupplierEmail       = SupplierEmail;
             ui.IsHidden            = IsHidden;
             ui.ModifiedBy          = ModifiedBy;
             ui.ModifiedDate        = ModifiedDate;
             int kq = dbe.SaveChanges();
             return(kq.ToString());
         }
         else
         {
             return(null);
         }
     }
 }
Пример #3
0
 protected void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtMaNhaCungCap.Text.Length > 0)
         {
             tbl_Supplier supplier = db.tbl_Supplier.Find(int.Parse(txtMaNhaCungCap.Text));
             db.tbl_Supplier.Remove(supplier);
             db.SaveChanges();
             load();
             reset();
             lbThongBao.Text      = "Xóa thành công";
             lbThongBao.ForeColor = System.Drawing.Color.Green;
         }
         else
         {
             lbThongBao.Text      = "Chưa chọn nhà cung cấp cần xóa";
             lbThongBao.ForeColor = System.Drawing.Color.Red;
         }
     }
     catch (Exception ex)
     {
         lbThongBao.Text      = "Đã có lỗi xảy ra. Vui lòng thử lại sau.";
         lbThongBao.ForeColor = System.Drawing.Color.Red;
     }
 }
Пример #4
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (KT(txtTenNCC.Text, txtDiachi.Text, txtPhone.Text))
     {
         tbl_Supplier s = new tbl_Supplier();
         s.Supplier_Name = txtTenNCC.Text;
         s.Address       = txtDiachi.Text;
         if (txtPhone.Text == "")
         {
             s.Phone = null;
         }
         else
         {
             s.Phone = int.Parse(txtPhone.Text);
         }
         s.Email = txtEmail.Text;
         var query = from a in db.tbl_Suppliers
                     select a;
         db.tbl_Suppliers.InsertOnSubmit(s);
         db.SubmitChanges();
         load();
         Label2.Text = "Thêm thành công";
         rong();
     }
     else
     {
         Label2.Text = "Chưa nhập đủ thông tin.";
     }
 }
Пример #5
0
 public ActionResult Edit([Bind(Include = "id,code,name,mobile,email,address")] tbl_Supplier tbl_supplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_supplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_supplier));
 }
Пример #6
0
        public PartialViewResult Edit(string id)
        {
            tbl_Supplier obj = (new SupplierService()).GetSupplierByID(id);

            if (obj == null)
            {
                obj = (new SupplierService()).InitEmpty();
            }
            return(PartialView("EditSupplier", obj));
        }
Пример #7
0
        // GET: /Supplier/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_Supplier tbl_supplier = db.tbl_Supplier.Find(id);

            if (tbl_supplier == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_supplier));
        }
Пример #8
0
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            Label        lblMa = (Label)GridView1.Rows[e.NewEditIndex].FindControl("lbMa");
            tbl_Supplier s     = db.tbl_Suppliers.SingleOrDefault(c => c.Supplier_ID == int.Parse(lblMa.Text));

            txtMa.Text          = (s.Supplier_ID).ToString();
            txtTenNCC.Text      = s.Supplier_Name.ToString();
            txtDiachi.Text      = s.Address.ToString();
            txtPhone.Text       = s.Phone.ToString();
            txtEmail.Text       = s.Email.ToString();
            GridView1.EditIndex = e.NewEditIndex;
            load();
            Label2.Text = "";
        }
Пример #9
0
        public ActionResult Create([Bind(Include = "id,code,name,mobile,email,address")] tbl_Supplier tbl_supplier)
        {
            if (ModelState.IsValid)
            {
                db.tbl_Supplier.Add(tbl_supplier);
                ViewBag.message = "Supplier Added Succesfully";
                db.SaveChanges();

                ModelState.Clear();
                return(View());
                //return RedirectToAction("Index");
            }

            return(View(tbl_supplier));
        }
Пример #10
0
 public static tbl_Supplier GetByID(int ID)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_Supplier ai = dbe.tbl_Supplier.Where(a => a.ID == ID).FirstOrDefault();
         if (ai != null)
         {
             return(ai);
         }
         else
         {
             return(null);
         }
     }
 }
Пример #11
0
        public tbl_Supplier InitEmpty()
        {
            var obj = new tbl_Supplier();

            obj.Id      = 0;
            obj.Address = "";
            obj.Code    = "";
            obj.Contact_Person_Email  = "";
            obj.Contact_Person_Mobile = "";
            obj.Contact_Person_Name   = "";
            obj.Contact_Person_Phone  = "";
            obj.Email = "";
            obj.Code  = (new CommService()).GetSupplierCode();
            return(obj);
        }
Пример #12
0
        public JsonResult DeleteConfirmed(int id)
        {
            string success = string.Empty;
            // return Json(success, JsonRequestBehavior.AllowGet);
            tbl_Supplier tbl_supplier = db.tbl_Supplier.Find(id);

            db.tbl_Supplier.Remove(tbl_supplier);
            int result = db.SaveChanges();

            if (result > 0)
            {
                success = "Data delete successfully";
            }
            //  return Json(success, JsonRequestBehavior.AllowGet);

            return(Json(new { result = success }));
        }
Пример #13
0
 protected void Button3_Click(object sender, EventArgs e)
 {
     if (KT(txtTenNCC.Text, txtDiachi.Text, txtPhone.Text))
     {
         tbl_Supplier s = db.tbl_Suppliers.SingleOrDefault(a => a.Supplier_ID == int.Parse(txtMa.Text));
         db.tbl_Suppliers.DeleteOnSubmit(s);
         db.SubmitChanges();
         load();
         Label2.Text = "Xoá thành công";
         rong();
         txtTenNCC.Focus();
     }
     else
     {
         Label2.Text = "Bạn chưa chọn nhà cung cấp.";
     }
 }
Пример #14
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     if (KT(txtTenNCC.Text, txtDiachi.Text, txtPhone.Text))
     {
         tbl_Supplier s = db.tbl_Suppliers.SingleOrDefault(a => a.Supplier_ID == int.Parse(txtMa.Text));
         s.Supplier_ID   = int.Parse(txtMa.Text);
         s.Supplier_Name = txtTenNCC.Text;
         s.Address       = txtDiachi.Text;
         s.Phone         = int.Parse(txtPhone.Text);
         s.Email         = txtEmail.Text;
         db.SubmitChanges();
         load();
         Label2.Text = "Sửa thành công";
         rong();
     }
     else
     {
         Label2.Text = "Bạn chưa chọn nhà cung cấp.";
     }
 }
Пример #15
0
 public static string Insert(string SupplierName, string SupplierDescription, string SupplierPhone, string SupplierAddress, string SupplierEmail,
                             bool IsHidden, DateTime CreatedDate, string CreatedBy)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_Supplier ui = new tbl_Supplier();
         ui.SupplierName        = SupplierName;
         ui.SupplierDescription = SupplierDescription;
         ui.SupplierPhone       = SupplierPhone;
         ui.SupplierAddress     = SupplierAddress;
         ui.SupplierEmail       = SupplierEmail;
         ui.IsHidden            = IsHidden;
         ui.CreatedDate         = CreatedDate;
         ui.CreatedBy           = CreatedBy;
         dbe.tbl_Supplier.Add(ui);
         dbe.SaveChanges();
         int kq = ui.ID;
         return(kq.ToString());
     }
 }
Пример #16
0
        public static bool SaveSupplier(string id, string name, string serviceCharge, string vat, string phone, string address, string country, string message, string currency)
        {
            InventoryBL  bl       = new InventoryBL();
            tbl_Supplier supplier = new tbl_Supplier()
            {
                Supplier_Id          = Convert.ToInt32(id),
                Supplier_Name        = name,
                Service_Charge_Value = serviceCharge,
                Vat_Charge_Value     = vat,
                Phone    = phone,
                Address  = address,
                Country  = country,
                Message  = message,
                Currency = currency
            };

            if (!bl.ValidateSupplier(supplier))
            {
                bool result = bl.SaveSupplier(supplier);
                return(result);
            }
            return(false);
        }
Пример #17
0
        public int UpdateOrInsertSupplier(tbl_Supplier obj)
        {
            using (var db = _connectionData.OpenDbConnection())
            {
                if (obj.Id > 0)
                {
                    var query     = db.From <tbl_Supplier>().Where(e => e.Id == obj.Id);
                    var objUpdate = db.Select(query).SingleOrDefault();
                    if (objUpdate != null)
                    {
                        objUpdate.Address = obj.Address;
                        //objUpdate.Code = obj.Code;
                        objUpdate.Name = obj.Name;
                        objUpdate.Contact_Person_Email  = obj.Contact_Person_Email;
                        objUpdate.Contact_Person_Mobile = obj.Contact_Person_Mobile;
                        objUpdate.Contact_Person_Name   = obj.Contact_Person_Name;
                        objUpdate.Contact_Person_Phone  = obj.Contact_Person_Phone;
                        objUpdate.Email = obj.Email;

                        return(db.Update(objUpdate));
                    }
                    return(-1);
                }
                else
                {
                    var queryCount = db.From <tbl_Supplier>().Where(e => e.Name == obj.Name && e.SysHotelID == comm.GetHotelId()).Select(e => e.Id);
                    var objCount   = db.Count(queryCount);
                    if (objCount > 0)
                    {
                        return(comm.ERROR_EXIST);
                    }
                    obj.SysHotelID = comm.GetHotelId();
                    return((int)db.Insert(obj, selectIdentity: true));
                }
            }
        }
Пример #18
0
        public ActionResult Update(tbl_Supplier obj)
        {
            int result = new SupplierService().UpdateOrInsertSupplier(obj);

            return(Json(new { result = result }, JsonRequestBehavior.AllowGet));
        }