Ejemplo n.º 1
0
        public JsonResult Event_Import_Event_Info(int rowIndex)
        {
            List <Message> ms_error = new List <Message>();

            if (Session["event_payment_error"] != null)
            {
                ms_error = (List <Message>)Session["list_file_error"];
            }

            Message   ms  = new Message();
            DataTable dt  = (DataTable)Session["event_payment"];
            DataTable dt2 = (DataTable)Session["history_payment"];
            DataTable dt3 = (DataTable)Session["service_cost"];

            var rowCurrent = dt.Rows[rowIndex];
            int id_Admin   = Services_Admin_Info.Instance().Get_ID_Admin(rowCurrent[1].ToString());

            if (id_Admin == 0)
            {
                ms.code = "1";
                ms.msg  = "Code admin của bạn không tồn tại , vui lòng kiểm tra lại . Cảm ơn !";
                return(Json(ms));
            }

            Event_Info model = new Event_Info()
            {
                Id_Admin_Info = id_Admin,
                Abbott_Code   = !string.IsNullOrEmpty(rowCurrent[2].ToString()) ? rowCurrent[2].ToString() : "",
                Name          = !string.IsNullOrEmpty(rowCurrent[3].ToString()) ? rowCurrent[3].ToString() : "",
                Event_Time    = !string.IsNullOrEmpty(rowCurrent[4].ToString()) ? DateTime.Parse(rowCurrent[4].ToString()) : (DateTime?)null,
                Request_Date  = !string.IsNullOrEmpty(rowCurrent[5].ToString()) ? DateTime.Parse(rowCurrent[5].ToString()) : (DateTime?)null,
                Area          = !string.IsNullOrEmpty(rowCurrent[6].ToString()) ? rowCurrent[6].ToString() : "",
                Description   = !string.IsNullOrEmpty(rowCurrent[7].ToString()) ? rowCurrent[7].ToString() : "",
                Note          = !string.IsNullOrEmpty(rowCurrent[8].ToString()) ? rowCurrent[8].ToString() : "",
                Status        = "Actived",
                Create_User   = Session["user"].ToString(),
                Create_Date   = DateTime.Now
            };

            ms = Services_Event_Info.Instance().Event_Import_Event_Info(model, rowIndex);
            var id_event = int.Parse(ms.sub_code);

            if (ms.code == "0")
            {
                dt2        = (DataTable)Session["history_payment"];
                rowCurrent = dt2.Rows[rowIndex];
                bool invoice_abb = false;
                if (rowCurrent[12].ToString().Equals("0"))
                {
                    invoice_abb = true;
                }

                History_Payment add2 = new History_Payment()
                {
                    HCP_Code             = !string.IsNullOrEmpty(rowCurrent[1].ToString()) ? rowCurrent[1].ToString() : "",
                    Number_Contract      = !string.IsNullOrEmpty(rowCurrent[2].ToString()) ? rowCurrent[2].ToString() : "",
                    FromDate             = !string.IsNullOrEmpty(rowCurrent[3].ToString()) ? DateTime.Parse(rowCurrent[3].ToString()) : (DateTime?)null,
                    ToDate               = !string.IsNullOrEmpty(rowCurrent[4].ToString()) ? DateTime.Parse(rowCurrent[4].ToString()) : (DateTime?)null,
                    Value_Contract       = !string.IsNullOrEmpty(rowCurrent[5].ToString()) ? Double.Parse(rowCurrent[5].ToString()) : (Double?)null,
                    PPL_GetContract_Date = !string.IsNullOrEmpty(rowCurrent[6].ToString()) ? DateTime.Parse(rowCurrent[6].ToString()) : (DateTime?)null,
                    Rep_Name             = !string.IsNullOrEmpty(rowCurrent[7].ToString()) ? rowCurrent[7].ToString() : "",
                    Sup_Name             = !string.IsNullOrEmpty(rowCurrent[8].ToString()) ? rowCurrent[8].ToString() : "",
                    Description          = !string.IsNullOrEmpty(rowCurrent[9].ToString()) ? rowCurrent[9].ToString() : "",
                    PPL_Payment_Date     = !string.IsNullOrEmpty(rowCurrent[10].ToString()) ? DateTime.Parse(rowCurrent[10].ToString()) : (DateTime?)null,
                    Payment_Value        = !string.IsNullOrEmpty(rowCurrent[11].ToString()) ? Double.Parse(rowCurrent[11].ToString()) : (Double?)null,
                    Invoice_Abbott       = invoice_abb,
                    Report_Abbott_Date   = !string.IsNullOrEmpty(rowCurrent[13].ToString()) ? DateTime.Parse(rowCurrent[13].ToString()) : (DateTime?)null,
                    Note        = !string.IsNullOrEmpty(rowCurrent[14].ToString()) ? rowCurrent[14].ToString() : "",
                    Status      = "Actived",
                    Create_User = Session["user"].ToString(),
                    Create_Date = DateTime.Now
                };
                ms = Services_History_Payment.Instance().Event_Import_History_Payment(add2, rowIndex, id_event);
            }
            if (ms.code == "0")
            {
                if (dt3.Rows.Count > (rowIndex))
                {
                    dt3        = (DataTable)Session["service_cost"];
                    rowCurrent = dt3.Rows[rowIndex];

                    Service_Cost add3 = new Service_Cost()
                    {
                        ID_Service_Criteria = int.Parse(rowCurrent[0].ToString()),
                        Honorarium_fee      = Double.Parse(rowCurrent[1].ToString()),
                        Air_ticket          = Double.Parse(rowCurrent[2].ToString()),
                        Meal_fee            = Double.Parse(rowCurrent[3].ToString()),
                        Hotel_fee           = Double.Parse(rowCurrent[4].ToString()),
                        Car_rental          = Double.Parse(rowCurrent[5].ToString()),
                        Other_fees          = Double.Parse(rowCurrent[6].ToString()),
                        Total_costs         = Double.Parse(rowCurrent[7].ToString()),
                        Status      = "Actived",
                        Create_User = Session["user"].ToString(),
                        Create_Date = DateTime.Now
                    };
                    ms = Services_service_costs.Instance().Event_Import_Service_Cost(add3, rowIndex, id_event);
                }
            }

            if (ms.code == "1")
            {
                ms_error.Add(ms);
                ms.code = "0";
            }
            if (rowIndex == dt.Rows.Count - 1)
            {
                if (ms_error.Count > 0)
                {
                    Session["list_file_error"] = ms_error;
                    ms.code     = "1";
                    ms.msg      = "Vui lòng xem file Excel Lỗi !";
                    ms.sub_code = "Danh Sách Thông Tin Sự Kiện & Thanh Toán Lỗi";
                }
                else
                {
                    ms.code = "2";
                    ms.msg  = "Đã Up Danh Sách Thông Tin Sự Kiện & Thanh Toán Thành Công";
                }
            }
            else
            {
                Session["list_file_error"] = ms_error;
            }
            return(Json(ms));
        }
Ejemplo n.º 2
0
        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));
        }