internal Message Event_Add_Edit_Event_Info(AddEventInfoClass form) { Message ms = new Message(); try { ms.code = "1"; ms.msg = ""; return(ms); } catch (Exception ex) { ms.code = "1"; ms.msg = ex.Message; return(ms); } }
public JsonResult Event_Add_Edit_Event_Info(string data) { AddEventInfoClass temp = JsonConvert.DeserializeObject <AddEventInfoClass>(data); Message ms = new Message(); using (var db = new HCB_ABBOTTEntities()) { //add event #region event Event_Info ei = new Event_Info(); ei.Abbott_Code = temp.form["Abbott_Code"]; ei.Id_Admin_Info = Int32.Parse(temp.form["Id_Admin_Info"]); ei.Name = temp.form["Name"]; ei.Event_Time = DateTime.Parse(temp.form["Event_Time"]); ei.Request_Date = DateTime.Parse(temp.form["Request_Date"]); ei.Area = temp.form["Area"]; ei.Description = temp.form["Description"]; ei.Note = temp.form["Note"]; ei.Status = "Actived"; ei.Create_Date = DateTime.Now; ei.Create_User = temp.form["CreateUser"]; db.Event_Info.Add(ei); db.SaveChanges(); #endregion //add s cost #region add sv cost string usr = Session["user"].ToString(); int id_username = db.UserNames.FirstOrDefault(r => r.UserName1 == usr).ID; for (int i = 1; i <= 8; i++) { var fee = temp.FeeJson[i.ToString()]; Service_Cost sc = new Service_Cost(); sc.ID_Event = ei.ID; sc.ID_Service_Criteria = i; sc.Honorarium_fee = fee.Fee; sc.Air_ticket = temp.TicketJson[i.ToString()].Tickets; sc.Meal_fee = temp.MealJson[i.ToString()].Meals; sc.Hotel_fee = temp.HotelJson[i.ToString()].Hotels; sc.Car_rental = temp.CarJson[i.ToString()].Cars; sc.Other_fees = temp.OtherJson[i.ToString()].Others; sc.Total_costs = double.Parse(temp.Totalrow[i - 1]); db.Service_Cost.Add(sc); db.SaveChanges(); } #endregion //add rate #region add rate //for (int i = 1; i <= 8; i++) //{ // if (i==2 || i==4 || i==7) { // User_Create_Rate us_cr = new User_Create_Rate(); // us_cr.Id_User_Name = id_username; // us_cr.Rate = temp.RateJson[i.ToString()].Ratenames; // us_cr.Status = "Actived"; // us_cr.Create_Date = DateTime.Now; // us_cr.Create_User = temp.form["CreateUser"]; // if(i == 2) { us_cr.Id_rate = 1; } // if (i == 4) { us_cr.Id_rate = 2; } // if (i == 7) { us_cr.Id_rate = 3; } // db.User_Create_Rate.Add(us_cr); // db.SaveChanges(); // } //} #endregion //add history payment #region history payment bool invoice_1 = false; if (temp.form["Invoice_Abbott"].ToString() == "0") { invoice_1 = true; } History_Payment hp = new History_Payment(); hp.Id_Event = ei.ID; hp.HCP_Code = temp.form["HCP_Code"]; hp.Number_Contract = temp.form["Number_Contract"]; hp.FromDate = DateTime.Parse(temp.form["FromDate"]); hp.ToDate = DateTime.Parse(temp.form["ToDate"]); hp.Value_Contract = double.Parse(temp.form["Value_Contract"]); hp.PPL_GetContract_Date = DateTime.Parse(temp.form["PPL_GetContract_Date"]); hp.Rep_Name = temp.form["Rep_Name"]; hp.Sup_Name = temp.form["Sup_Name"]; hp.Description = temp.form["Description"]; //hp.Requested_Value = double.Parse(temp.form["Requested_Value"]); //hp.Requested_Date = DateTime.Parse(temp.form["Requested_Date"]); hp.PPL_Payment_Date = DateTime.Parse(temp.form["PPL_Payment_Date"]); hp.Payment_Value = double.Parse(temp.form["Payment_Value"]); hp.Invoice_Abbott = invoice_1; hp.Report_Abbott_Date = DateTime.Parse(temp.form["Report_Abbott_Date"]); //hp.Account_Name = temp.form["Account_Name"]; hp.Note = temp.form["Note"]; hp.Status = "Actived"; hp.Create_User = temp.form["CreateUser"]; hp.Create_Date = DateTime.Now; db.History_Payment.Add(hp); db.SaveChanges(); #endregion ms.code = "0"; ms.msg = "Thêm Thành Công !"; } Session["idEvent"] = ms.sub_code; return(Json(ms)); }