public ActionResult Edit(ServiceOtherPrice ServiceOtherPrice, string codeSystem, string typeName) { ServiceOtherPrice.ServiceOtherPriceId = Convert.ToInt32(DefineFuntion.Decrypt(codeSystem)); int ms = 0; var me = db.ServiceOtherPrices.Find(ServiceOtherPrice.ServiceOtherPriceId); try { me.Name = ServiceOtherPrice.Name; me.Status = ServiceOtherPrice.Status; me.FromDay = ServiceOtherPrice.FromDay; me.ToDay = ServiceOtherPrice.ToDay; me.Price = ServiceOtherPrice.Price; me.PriceAdult = ServiceOtherPrice.PriceAdult; me.PriceChild = ServiceOtherPrice.PriceChild; me.PriceInfant = ServiceOtherPrice.PriceInfant; me.PriceBaby = ServiceOtherPrice.PriceBaby; db.SaveChanges(); ms = 3;//Nếu cập nhật thành công //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Cập Nhật Giá Dịch Vụ", Contens = JsonConvert.SerializeObject(me, Formatting.Indented, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), ItemId = me.ServiceOtherPriceId, Type = (int)DefineFuntion.TypeHistory.ServiceOtherPrice, }); } catch (Exception) { ms = 4;//Nếu cập nhật không thành công } if (typeName == "savenew" || typeName == "") { return(RedirectToAction("Create", new { mess = ms })); } else { return(RedirectToAction("Edit", new { id = codeSystem, mess = ms })); } }
public int DeleteConfirmed(string[] inputCheck) { //System.Windows.Forms.DialogResult dailogresult = System.Windows.Forms.MessageBox.Show("Bạn có chắc chắn xóa!", "Thông báo", System.Windows.Forms.MessageBoxButtons.YesNo); int rowFinish = 0; if (inputCheck == null) { return(rowFinish); } foreach (var s in inputCheck) { try { int idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s)); ServiceOtherPrice obj = db.ServiceOtherPrices.Find(idMenu); //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Xóa Giá Dịch Vụ", Contens = JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), ItemId = obj.ServiceOtherPriceId, Type = (int)DefineFuntion.TypeHistory.ServiceOther, }); db.ServiceOtherPrices.Remove(obj); db.SaveChanges(); rowFinish++; } catch (Exception) { int idMenu = Convert.ToInt32(DefineFuntion.Decrypt(s)); ServiceOtherPrice obj = db.ServiceOtherPrices.Find(idMenu); obj.Status = 3; db.SaveChanges(); } } return(rowFinish); }
public ActionResult Create(ServiceOtherPrice ServiceOtherPrice, string typeName) { var shared = new SharedFuntionController(); int ms = 0; try { db.ServiceOtherPrices.Add(ServiceOtherPrice); db.SaveChanges(); ms = 1; //1-them, 2- sua, 3-xoa, 4- khac shared.CreateHistory(new History() { Name = "Thêm Giá Dịch Vụ", Contens = "", ItemId = ServiceOtherPrice.ServiceOtherPriceId, Type = (int)DefineFuntion.TypeHistory.ServiceOther, }); } catch (Exception) { ms = 2; } if (ms != 2) { if (typeName == "savenew" || typeName == "") { return(RedirectToAction("Create", new { mess = ms })); } else { return(RedirectToAction("Edit", new { id = DefineFuntion.Encrypt(ServiceOtherPrice.ServiceOtherPriceId), mess = ms })); } } ViewBag.Status = new SelectList(DefineFuntion.ListStatus, "Value", "Text", ServiceOtherPrice.Status); return(View("Create", "ServiceOtherPrice")); }