Esempio n. 1
0
 public ActionResult Update(int incident_id, string reason, int year, int month, int day, int hour, int minute)
 {
     using (QuangHanhManufacturingEntities DBContext = new QuangHanhManufacturingEntities())
     {
         try
         {
             Incident1 i   = DBContext.Incident1.Find(incident_id);
             DateTime  end = new DateTime(year, month, day, hour, minute, 0);
             if (DateTime.Compare(i.start_time, end) >= 0)
             {
                 return(Json(new { success = false, message = "Thời gian bắt đầu phải nhỏ hơn thời gian kết thúc" }));
             }
             if (i == null)
             {
                 return(Json(new { success = false, message = "Mã sự cố sai" }));
             }
             else
             {
                 i.reason   = reason;
                 i.end_time = new DateTime(year, month, day, hour, minute, 0);
                 i.Equipment.current_status = 1;
                 DBContext.SaveChanges();
                 return(Json(new { success = true, message = "Cập nhật thành công" }));
             }
         }
         catch (Exception)
         {
             return(Json(new { success = false, message = "Có lỗi xảy ra, xin vui lòng thử lại" }));
         }
     }
 }
Esempio n. 2
0
        public ActionResult List(string type, string date, string month, string quarter, string year)
        {
            string query;

            if (type == null)
            {
                var ngay = DateTime.Now.Date.ToString("dd/MM/yyyy");
                query = Wherecondition("day", ngay, null, null, null);
            }
            else
            {
                query = Wherecondition(type, date, month, quarter, year);
            }
            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                List <contentreportWater> listdata = db.Database.SqlQuery <contentreportWater>(query).ToList();
                foreach (var item in listdata)
                {
                    item.LuongTieuThu = Math.Round(item.LuongTieuThu, 1);
                }
                var js            = Json(new { success = true, data = listdata }, JsonRequestBehavior.AllowGet);
                var dataserialize = new JavaScriptSerializer().Serialize(js.Data);
                return(js);
            }
        }
Esempio n. 3
0
        public ActionResult list()
        {
            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                try
                {
                    //search data
                    string search_work_group_name    = Request["search_work_group_name"];
                    string search_work_group_acronym = Request["search_work_group_acronym"];
                    string search_work_group_type    = Request["search_work_group_type"];

                    //get data's table to paging
                    int    start          = Convert.ToInt32(Request["start"]);
                    int    length         = Convert.ToInt32(Request["length"]);
                    string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
                    string sortDirection  = Request["order[0][dir]"];

                    List <GetDataWorkGroups_Result> workGroups = db.Database.SqlQuery <GetDataWorkGroups_Result>(@"HumanResources.GetDataWorkGroups {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}",
                                                                                                                 "", search_work_group_name, search_work_group_acronym, search_work_group_type, sortColumnName, sortDirection, start, length, "DataTable").ToList();

                    int totalrows = db.WorkGroups.Count();
                    int totalrowsafterfiltering = totalrows;

                    return(Json(new { workGroups = workGroups, recordsTotal = totalrows, recordsFiltered = totalrowsafterfiltering }, JsonRequestBehavior.AllowGet));
                } catch (Exception e)
                {
                    throw e;
                }
            }
        }
        public ActionResult Add(string supply_id, string supply_name, string unit)
        {
            QuangHanhManufacturingEntities DBContext = new QuangHanhManufacturingEntities();
            Supply s = DBContext.Supplies.Find(supply_id);

            if (supply_id.Trim() == "")
            {
                return(Json(new { success = false, message = "Không được để trống trường Mã vật tư" }, JsonRequestBehavior.AllowGet));
            }
            else
            if (supply_name.Trim() == "")
            {
                return(Json(new { success = false, message = "Không được để trống trường Tên vật tư" }, JsonRequestBehavior.AllowGet));
            }
            else
            if (unit.Trim() == "")
            {
                return(Json(new { success = false, message = "Không được để trống trường Đơn vị" }, JsonRequestBehavior.AllowGet));
            }
            else
            if (s != null)
            {
                return(Json(new { success = false, message = "Vật tư đã tồn tại" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                s             = new Supply();
                s.supply_id   = supply_id;
                s.supply_name = supply_name;
                s.unit        = unit;
                DBContext.Supplies.Add(s);
                DBContext.SaveChanges();
                return(Json(new { success = true, message = "Tạo loại vật tư thành công" }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 5
0
        public ActionResult Export(string type, string date, string month, string quarter, string year)
        {
            string   path       = HostingEnvironment.MapPath("/excel/CDVT/thoatnuoc.xlsx");
            string   saveAsPath = ("/excel/CDVT/download/thoatnuoc.xlsx");
            FileInfo file       = new FileInfo(path);

            using (ExcelPackage excelPackage = new ExcelPackage(file))
            {
                ExcelWorkbook  excelWorkbook  = excelPackage.Workbook;
                ExcelWorksheet excelWorksheet = excelWorkbook.Worksheets.First();
                using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
                {
                    string query;
                    if (type == null)
                    {
                        var ngay = DateTime.Now.Date.ToString("dd/MM/yyyy");
                        query = Wherecondition("day", ngay, null, null, null);
                    }
                    else
                    {
                        query = Wherecondition(type, date, month, quarter, year);
                    }
                    List <contentreportWater> content = db.Database.SqlQuery <contentreportWater>(query).ToList();
                    double totaltieuhao = 0; double totalsanluong = 0; double totalgio = 0;
                    if (content != null)
                    {
                        foreach (var item in content)
                        {
                            totaltieuhao  += item.LuongTieuThu;
                            totalsanluong += item.SanLuong;
                            totalgio      += item.GioHoatDong;
                        }
                    }
                    int k = 3;
                    for (int i = 0; i < content.Count; i++)
                    {
                        excelWorksheet.Cells[k, 1].Value = content.ElementAt(i).Thang + "/" + content.ElementAt(i).Nam;
                        excelWorksheet.Cells[k, 2].Value = content.ElementAt(i).TenThietBi;
                        excelWorksheet.Cells[k, 3].Value = content.ElementAt(i).MaThietBi;
                        excelWorksheet.Cells[k, 4].Value = content.ElementAt(i).MaTSCD;
                        excelWorksheet.Cells[k, 5].Value = content.ElementAt(i).ViTriDat;
                        excelWorksheet.Cells[k, 6].Value = content.ElementAt(i).GioHoatDong;
                        excelWorksheet.Cells[k, 7].Value = content.ElementAt(i).LuongTieuThu;
                        excelWorksheet.Cells[k, 8].Value = content.ElementAt(i).SanLuong;
                        k++;
                    }
                    excelWorksheet.Cells[k, 5].Value           = "Tổng";
                    excelWorksheet.Cells[k, 6].Value           = totalgio;
                    excelWorksheet.Cells[k, 7].Value           = totaltieuhao;
                    excelWorksheet.Cells[k, 8].Value           = totalsanluong;
                    excelWorksheet.Cells[k, 5].Style.Font.Bold = true;
                    excelWorksheet.Cells[k, 5].Style.Font.Color.SetColor(System.Drawing.Color.Red);
                    excelWorksheet.Cells[k, 6].Style.Font.Color.SetColor(System.Drawing.Color.Red);
                    excelWorksheet.Cells[k, 7].Style.Font.Color.SetColor(System.Drawing.Color.Red);
                    excelWorksheet.Cells[k, 8].Style.Font.Color.SetColor(System.Drawing.Color.Red);
                    excelPackage.SaveAs(new FileInfo(HostingEnvironment.MapPath(saveAsPath)));
                }
            }
            return(Json(new { success = true, location = saveAsPath }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        public JsonResult DeleteWork(string maCT, string id)
        {
            List <WorkingProcess> list = new List <WorkingProcess>();

            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                using (DbContextTransaction transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        string query = @"delete from [HumanResources].WorkingProcess where working_process_id = {0}
                                         select * from [HumanResources].WorkingProcess where employee_id = {1}";
                        list = db.Database.SqlQuery <WorkingProcess>(query, maCT, id).ToList();
                        transaction.Commit();
                    }
                    catch (Exception e)
                    {
                        transaction.Rollback();
                        return(Json(new { success = false, message = "Lỗi!" + e.Message }, JsonRequestBehavior.AllowGet));
                    }
                }

                return(Json(new { success = true, listCT = list }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult List()
        {
            int    start          = Convert.ToInt32(Request["start"]);
            int    length         = Convert.ToInt32(Request["length"]);
            string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
            string sortDirection  = Request["order[0][dir]"];

            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                string query = @"select c.TenChungChi, CONVERT(varchar, cn.NgayCap, 103) as NgayCap, CONVERT(varchar, DATEADD(MONTH, c.ThoiHan, cn.NgayCap), 103) as NgayHetHan, COUNT(*) as SoLuong from ChungChi c
                    join ChungChi_NhanVien cn on c.MaChungChi = cn.MaChungChi
                    WHERE c.TenChungChi like @TenChungChi
                    GROUP BY c.TenChungChi, cn.NgayCap, c.ThoiHan";

                var listdata = db.Database.SqlQuery <BaoCaoChungChi>(query +
                                                                     " ORDER BY " + sortColumnName + " " + sortDirection +
                                                                     " OFFSET " + start + " ROWS FETCH NEXT " + length + " ROWS ONLY",
                                                                     new SqlParameter("TenChungChi", "%" + Request["TenChungChi"] + "%")).ToList();

                int totalrows = db.Database.SqlQuery <int>("select count(*) from (" + query + ") as d",
                                                           new SqlParameter("TenChungChi", "%" + Request["TenChungChi"] + "%")).FirstOrDefault();

                return(Json(new { success = true, data = listdata, draw = Request["draw"], recordsTotal = totalrows, recordsFiltered = totalrows }));
            }
        }
        private int month_summary_count(string SupplyId, string SupplyName, string month)
        {
            var val = month.Split(' ');
            QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities();
            int recordsTotal = db.Database.SqlQuery <int>(@" select count(SupplyId) from(select (case when a.supply_id is null then b.supplyid else a.supply_id end) 'SupplyId', 
(case when a.supply_name is null then b.supply_name else a.supply_name end) 'SupplyName', 

(case when b.quantity_provide is null then 0 else b.quantity_provide end) 'SupplyProvide',
(case when b.quantity is null then 0 else b.quantity end) 'SupplyQuantity',

(case when a.unit is null then b.unit else a.unit end) 'SupplyUnit',
sum(case when a.used is null then 0 else a.used end) 'SupplyUsed', 
sum(case when a.thuhoi is null then 0 else a.thuhoi end) 'SupplyEviction'
from
(select s.supply_id, s.supply_name, s.unit,
esd.used,esd.thuhoi
from Supply s inner join Equipment_SCTX_Detail esd
on s.supply_id = esd.supplyid inner join Equipment_SCTX es on es.maintain_id = esd.maintain_id

and MONTH(es.[date]) = @month AND YEAR(es.[date]) = @year
group by s.supply_id, s.supply_name,  s.unit,esd.used,esd.thuhoi
union all
select s.supply_id, s.supply_name,  s.unit,
mcd.used,mcd.thuhoi
from Supply s inner join Maintain_Car_Detail mcd
on s.supply_id = mcd.supplyid inner join Maintain_Car mc on mc.maintainid = mcd.maintainid

and MONTH(mc.[date]) = @month AND YEAR(mc.[date]) = @year
group by s.supply_id,  s.supply_name, s.unit,mcd.used,mcd.thuhoi
union all
select s.supply_id, s.supply_name, s.unit,
sum(fac.consumption_value) 'used',
0 'thuhoi'
from Supply s inner join Fuel_activities_consumption fac
on s.supply_id = fac.fuel_type 
and MONTH(fac.[date]) = @month AND YEAR(fac.[date]) = @year 

group by s.supply_id, s.supply_name,  s.unit

) as a 
full outer join 
(select sp.supplyid, s.supply_name, sum(sp.quantity) 'quantity',sum(sp.quantity_provide) 'quantity_provide', s.unit
from Supply s inner join SupplyPlan sp
on s.supply_id = sp.supplyid 
where MONTH(sp.[date]) = @month and year(sp.[date]) = @year and sp.departmentid != 'CV'
group by  sp.supplyid, s.supply_name, s.unit
) as b
on  a.supply_id = b.supplyid 
where (a.supply_id like @supplyid or b.supplyid  like @supplyid ) 
and (a.supply_name like @supplyname  or b.supply_name like @supplyname ) 
group by a.supply_id, b.supplyid,b.quantity,  a.supply_name, b.supply_name,
 a.unit, b.unit,b.quantity_provide) as t", new SqlParameter("month", val[1]),
                                                          new SqlParameter("year", val[2]),
                                                          new SqlParameter("supplyid", "%" + SupplyId + "%"),

                                                          new SqlParameter("supplyname", "%" + SupplyName + "%")).FirstOrDefault();


            return(recordsTotal);
        }
Esempio n. 9
0
        public ActionResult AddOrEdit(string id = "")
        {
            List <SelectListItem> listDepeartment = new List <SelectListItem>();
            List <SelectListItem> listCategory    = new List <SelectListItem>();

            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                var departments = db.Departments.ToList <Department>();
                foreach (Department items in departments)
                {
                    listDepeartment.Add(new SelectListItem {
                        Text = items.department_id, Value = items.department_id
                    });
                }
                //
                var categories = db.Categories.ToList <Category>();
                foreach (Category items in categories)
                {
                    listCategory.Add(new SelectListItem {
                        Text = items.equipment_category_id, Value = items.equipment_category_id
                    });
                }
                //listForSelect.Add(new SelectListItem { Text = "Your text", Value = "TRAI" });
                ViewBag.listDepeartment = listDepeartment;
                ViewBag.listCategory    = listCategory;
                if (id == "" || id == null)
                {
                    return(View(new Equipment()));
                }
                else
                {
                    return(View(db.Equipments.Where(x => x.equipment_id == id).FirstOrDefault <Equipment>()));
                }
            }
        }
        public ActionResult Edit(int incident_id, string department, string reason, int quan, int yearStart, int monthStart, int dayStart, int hourStart, int minuteStart, int yearEnd, int monthEnd, int dayEnd, int hourEnd, int minuteEnd)
        {
            QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities();

            using (DbContextTransaction transaction = db.Database.BeginTransaction())
            {
                try
                {
                    Incident i     = db.Incidents.Find(incident_id);
                    Room     d     = db.Rooms.Where(x => x.room_name.Equals(department)).FirstOrDefault();
                    DateTime start = new DateTime(yearStart, monthStart, dayStart, hourStart, minuteStart, 0);
                    DateTime end   = new DateTime(yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, 0);
                    if (DateTime.Compare(start, end) >= 0)
                    {
                        return(Json(new { success = false, message = "Bạn đã nhập ngày bắt đầu lớn hơn ngày kết thúc" }, JsonRequestBehavior.AllowGet));
                    }
                    i.room_id    = d.room_id;
                    i.reason     = reason;
                    i.start_time = start;
                    i.end_time   = end;
                    i.incident_camera_quantity = quan;


                    db.SaveChanges();
                    transaction.Commit();
                    return(Json(new { success = true, message = "Chỉnh sửa thành công" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return(Json(new { success = false, message = "Có lỗi xảy ra, xin vui lòng thử lại" }, JsonRequestBehavior.AllowGet));
                }
            }
        }
        public ActionResult ChangeID(string id, string ck)
        {
            string sql = "";

            if (ck.Equals("0"))
            {
                sql = @"select supply_name as SupplyId from Supply where supply_name like @id";
            }
            else if (ck.Equals("1"))
            {
                sql = @"select supply_id as SupplyId from Supply where supply_id like @id ";
            }
            else if (ck.Equals("2"))
            {
                sql = @"select department_id as SupplyId from Department where department_id like @id";
            }
            else if (ck.Equals("3"))
            {
                sql = @"select department_name as SupplyId from Department where department_name like @id";
            }
            QuangHanhManufacturingEntities db   = new QuangHanhManufacturingEntities();
            List <SupplySearch>            list = db.Database.SqlQuery <SupplySearch>(sql, new SqlParameter("id", "%" + id + "%")).Take(10).ToList();

            return(Json(new { success = true, id = list }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Export(string type, string date, string month, string quarter, string year)
        {
            string   path       = HostingEnvironment.MapPath("/excel/CDVT/nhienlieu.xlsx");
            string   saveAsPath = ("/excel/CDVT/download/nhienlieu.xlsx");
            FileInfo file       = new FileInfo(path);

            using (ExcelPackage excelPackage = new ExcelPackage(file))
            {
                ExcelWorkbook  excelWorkbook  = excelPackage.Workbook;
                ExcelWorksheet excelWorksheet = excelWorkbook.Worksheets.First();
                using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
                {
                    if (type == null)
                    {
                        date = DateTime.Now.Date.ToString("dd/MM/yyyy");
                    }
                    List <GetFuelReport_Result> listdata = db.Database.SqlQuery <GetFuelReport_Result>("Equipment.GetFuelReport {0}, {1}, {2}, {3}, {4}", type, date, month, quarter, year).ToList();
                    int k = 3;
                    for (int i = 0; i < listdata.Count; i++)
                    {
                        excelWorksheet.Cells[k, 1].Value = listdata.ElementAt(i).Thang + "/" + listdata.ElementAt(i).Nam;
                        excelWorksheet.Cells[k, 2].Value = listdata.ElementAt(i).MaThietBi;
                        excelWorksheet.Cells[k, 3].Value = listdata.ElementAt(i).TenThietBi;
                        excelWorksheet.Cells[k, 4].Value = listdata.ElementAt(i).LoaiNhienLieu;
                        excelWorksheet.Cells[k, 5].Value = listdata.ElementAt(i).LuongTieuThu;
                        excelWorksheet.Cells[k, 6].Value = listdata.ElementAt(i).DonVi;
                        k++;
                    }
                    excelPackage.SaveAs(new FileInfo(HostingEnvironment.MapPath(saveAsPath)));
                }
            }
            return(Json(new { success = true, location = saveAsPath }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 13
0
        public ActionResult GetData()
        {
            //Server Side Parameter
            int    start          = Convert.ToInt32(Request["start"]);
            int    length         = Request["length"] == "-1" ? int.MaxValue : Convert.ToInt32(Request["length"]);
            string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
            string sortDirection  = Request["order[0][dir]"];
            string room_name      = Request["location"];
            string disk_status    = Request["status"];
            string reason         = Request["reason"];
            string department     = Request["department"];

            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                var sql = "select r.*, d.department_name from Room r " +
                          "inner join Department d on r.department_id = d.department_id " +
                          "where r.room_name like @room_name and r.disk_status like @disk_status and r.department_id like @department_id and r.camera_quantity != 0";
                if (reason != "")
                {
                    sql += " and r.signal_loss_reason like @signal_loss_reason";
                }
                var equipList = db.Database.SqlQuery <camDB>(sql + " order by " + sortColumnName + " " + sortDirection + " OFFSET " + start + " ROWS FETCH NEXT " + length + " ROWS ONLY",
                                                             new SqlParameter("room_name", '%' + room_name + '%'),
                                                             new SqlParameter("disk_status", '%' + disk_status + '%'),
                                                             new SqlParameter("department_id", '%' + department + '%'),
                                                             new SqlParameter("signal_loss_reason", '%' + reason + '%')).ToList();
                int totalrows = db.Database.SqlQuery <int>(sql.Replace("r.*, d.department_name", "count(*)"),
                                                           new SqlParameter("room_name", '%' + room_name + '%'),
                                                           new SqlParameter("disk_status", '%' + disk_status + '%'),
                                                           new SqlParameter("department_id", '%' + department + '%'),
                                                           new SqlParameter("signal_loss_reason", '%' + reason + '%')).FirstOrDefault();
                return(Json(new { success = true, data = equipList, draw = Request["draw"], recordsTotal = totalrows, recordsFiltered = totalrows }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 14
0
        public ActionResult Index()
        {
            QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities();
            string departID   = Session["departID"].ToString();
            string departName = Session["departName"].ToString();
            List <EquipWithDepart_Result> equipments = new List <EquipWithDepart_Result>();

            if (departID == "ĐK" || departID == "CV")
            {
                equipments = (from x in db.Equipments
                              join d in db.Departments on x.department_id equals d.department_id
                              select new EquipWithDepart_Result
                {
                    equipment_id = x.equipment_id,
                    equipment_name = x.equipment_name,
                    department_name = d.department_name
                }).ToList();
            }
            else
            {
                equipments = db.Equipments.Where(x => x.department_id.Equals(departID)).Select(x => new EquipWithDepart_Result
                {
                    equipment_id    = x.equipment_id,
                    equipment_name  = x.equipment_name,
                    department_name = departName
                }).ToList();
            }
            List <string> departments = db.Departments.Select(x => x.department_name).ToList();

            ViewBag.equipments  = equipments;
            ViewBag.departments = departments;
            return(View("/Views/CDVT/Suco/SucoThietbi.cshtml"));
        }
Esempio n. 15
0
 public ActionResult Search(string MaNV, string TenNV, string Gender, string pb)
 {
     try
     {
         int    start                      = Convert.ToInt32(Request["start"]);
         int    length                     = Convert.ToInt32(Request["length"]);
         string searchValue                = Request["search[value]"];
         string sortColumnName             = Request["columns[" + Request["order[0][column]"] + "][name]"];
         string sortDirection              = Request["order[0][dir]"];
         QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities();
         db.Configuration.LazyLoadingEnabled = false;
         string query_list = @"HumanResources.GetListEmployees {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}";
         List <GetListEmployees_Result> employees = db.Database.SqlQuery <GetListEmployees_Result>(query_list,
                                                                                                   MaNV, TenNV, Gender, pb, sortColumnName, sortDirection, start, length).ToList();
         Session["excel"] = db.Database.SqlQuery <GetListEmployees_Result>(query_list,
                                                                           MaNV, TenNV, Gender, pb, sortColumnName, sortDirection, start, 2147483647).ToList();
         string query_count = @"HumanResources.GetCountEmployees {0}, {1}, {2}, {3}";
         GetCountEmployees_Result get_count_employees = db.Database.SqlQuery <GetCountEmployees_Result>(query_count,
                                                                                                        MaNV, TenNV, Gender, pb).FirstOrDefault();
         int?totalrows = 0;
         if (get_count_employees != null)
         {
             totalrows = get_count_employees.count;
         }
         return(Json(new { data = employees, draw = Request["draw"], recordsTotal = totalrows, recordsFiltered = totalrows }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(new { data = "", draw = Request["draw"], recordsTotal = 0, recordsFiltered = 0 }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 16
0
        public ActionResult AddCategory()
        {
            List <SelectListItem> listType = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Lộ thiên", Value = "Lộ thiên"
                },
                new SelectListItem {
                    Text = "Hầm lò", Value = "Hầm lò"
                },
                new SelectListItem {
                    Text = "Sàng tuyển", Value = "Sàng tuyển"
                },
                new SelectListItem {
                    Text = "Cung cấp điện, truyền dẫn", Value = "Cung cấp điện, truyền dẫn"
                }
            };

            ViewBag.listType = listType;
            QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities();
            List <Supply> listSup             = db.Supplies.ToList <Supply>();

            ViewBag.listSup = listSup;
            return(View(new Category()));
        }
Esempio n. 17
0
        public JsonResult DeleteFamily(string family_type, string id, string family_relation)
        {
            List <GetFamiliesOfAnEmployee_Result> qhList = new List <GetFamiliesOfAnEmployee_Result>();

            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                using (DbContextTransaction transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        string query = @"delete from [HumanResources].Family where 
                                        employee_id = {0} and 
                                        family_relationship_id = {1} and 
                                        family_type_id = {2}
                                        exec [HumanResources].GetFamiliesOfAnEmployee {3}";
                        qhList = db.Database.SqlQuery <GetFamiliesOfAnEmployee_Result>
                                     (query, id, family_relation, family_type, id).ToList();
                        transaction.Commit();
                    }
                    catch (Exception e)
                    {
                        transaction.Rollback();
                        return(Json(new { success = false, message = "Lỗi!" + e.Message }, JsonRequestBehavior.AllowGet));
                    }
                }
                return(Json(new { success = true, listQH = qhList }, JsonRequestBehavior.AllowGet));
            }
        }
 public ActionResult getDataFromWorkByWorkID()
 {
     try
     {
         int work_id = Convert.ToInt32(Request["work_id"]);
         using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
         {
             var sqlGetData = @"select w.work_id, w.name, w.allowance, w.pay_table_id 
                                 from HumanResources.Work w 
                                 where w.work_id = @work_id";
             var list_works = db.Database.SqlQuery <Work_Extend>(sqlGetData, new SqlParameter("work_id", work_id)).FirstOrDefault();
             if (list_works != null)
             {
                 return(Json(new { success = true, list_works = list_works }));
             }
             else
             {
                 return(Json(new { success = false, title = "Có lỗi", message = "Không tìm thấy dữ liệu về công việc tương ứng." }));
             }
         }
     }
     catch (Exception e)
     {
         return(Json(new { error = true, title = "Có lỗi", message = "Có lỗi xảy ra." }));
     }
 }
Esempio n. 19
0
 public ActionResult Water(string type, string date, string month, string quarter, string year)
 {
     using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
     {
         if (type == null)
         {
             date = DateTime.Now.Date.ToString("dd/MM/yyyy");
         }
         List <GetWaterReport_Result> listdata = db.Database.SqlQuery <GetWaterReport_Result>("Equipment.GetWaterReport {0}, {1}, {2}, {3}, {4}", type, date, month, quarter, year).ToList();
         if (listdata != null)
         {
             double totaltieuhao = 0; double totalsanluong = 0; double totalgio = 0;
             foreach (var item in listdata)
             {
                 totaltieuhao     += item.LuongTieuThu;
                 totalsanluong    += item.SanLuong;
                 totalgio         += item.GioHoatDong;
                 item.LuongTieuThu = Math.Round(item.LuongTieuThu, 1);
             }
             ViewBag.TieuHao     = totaltieuhao;
             ViewBag.SanLuong    = totalsanluong;
             ViewBag.GioHoatDong = totalgio;
         }
     }
     return(View("/Views/CDVT/Report/WaterReport.cshtml"));
 }
Esempio n. 20
0
 public ActionResult Edit()
 {
     try
     {
         using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
         {
             Room r = db.Rooms.Find(Request["room_id"]);
             r.capacity           = Request["capacity"];
             r.disk_status        = Request["status"];
             r.series             = Request["serial"];
             r.note               = Request["note"];
             r.room_name          = Request["location"];
             r.department_id      = Request["department"];
             r.camera_quantity    = int.Parse(Request["quantity"].ToString());
             r.camera_available   = int.Parse(Request["quantity"].ToString());
             r.signal_loss_reason = "";
             r.login_information  = Request["login"];
             db.SaveChanges();
             return(Json(new { success = true, message = "Chỉnh sửa thành công" }));
         }
     }
     catch (Exception)
     {
         return(Json(new { success = false, message = "Có lỗi xảy ra" }));
     }
 }
        public ActionResult List()
        {
            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                db.Configuration.LazyLoadingEnabled = true;

                //get data's table to paging
                int    start          = Convert.ToInt32(Request["start"]);
                int    length         = Convert.ToInt32(Request["length"]);
                string searchValue    = Request["search[value]"];
                string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
                string sortDirection  = Request["order[0][dir]"];

                try
                {
                    List <Work_Extend> list_works = new List <Work_Extend>();
                    var sqlList = @"select w.work_id, w.name, w.allowance, pt.pay_table 
                                    from HumanResources.Work w 
                                    left outer join HumanResources.PayTable pt on w.pay_table_id = pt.pay_table_id 
                                    order by " + sortColumnName + " " + sortDirection + " OFFSET " + start + " ROWS FETCH NEXT " + length + " ROWS ONLY";
                    list_works = db.Database.SqlQuery <Work_Extend>(sqlList).ToList();

                    int totalrows = db.Works.Count();
                    int totalrowsafterfiltering = totalrows;
                    return(Json(new { list_works = list_works, recordsTotal = totalrows, recordsFiltered = totalrowsafterfiltering }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception e)
                {
                }
                return(null);
            }
        }
Esempio n. 22
0
        public ActionResult SetPhoto()
        {
            QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities();

            using (DbContextTransaction transaction = db.Database.BeginTransaction())
            {
                try
                {
                    Room   r           = db.Rooms.Find(Request["room_id"]);
                    string path        = "/images/camera/";
                    Image  sourceimage = Image.FromStream(Request.Files["img"].InputStream, true, true);
                    r.image_link = r.room_id + ".jfif";
                    db.SaveChanges();
                    if (!Directory.Exists(HostingEnvironment.MapPath(path)))
                    {
                        Directory.CreateDirectory(HostingEnvironment.MapPath(path));
                    }
                    if (sourceimage.Size != null)
                    {
                        sourceimage.Save(HostingEnvironment.MapPath(path + r.image_link));
                    }
                    transaction.Commit();
                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Esempio n. 23
0
        public ActionResult Delete()
        {
            try
            {
                int documentary_id = int.Parse(Request["documentary_id"]);
                using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
                {
                    Documentary doc = db.Documentaries.Find(documentary_id);
                    if (doc == null)
                    {
                        return(Json(new { success = false, message = "Mã quyết định không tồn tại" }));
                    }

                    if (doc.documentary_code != null)
                    {
                        return(Json(new { success = false, message = "Bạn không được xóa quyết định này" }));
                    }

                    db.Documentaries.Remove(doc);
                    db.SaveChanges();
                    return(Json(new { success = true, message = "Xóa thành công" }));
                }
            }
            catch (Exception)
            {
                return(Json(new { success = false, message = "Có lỗi xảy ra" }));
            }
        }
Esempio n. 24
0
        public ActionResult DeleteDepartment(string department_id)
        {
            try
            {
                using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
                {
                    var department = db.Departments.Find(department_id);
                    db.Departments.Remove(department);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        return(Json(new { success = false, message = "Dữ liệu bạn xóa đang tồn tại ở những màn hình khác. Do vậy để xóa phân xưởng này bạn phải xóa dữ liệu tại các màn hình có liên quan tới dữ liệu trên." }));
                    }

                    return(Json(new { success = true, message = "Xóa phân xưởng thành công." }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = "Có lỗi xảy ra." }));
            }
        }
Esempio n. 25
0
        public ActionResult Water(string type, string date, string month, string quarter, string year)
        {
            string query;

            if (type == null)
            {
                var ngay = DateTime.Now.Date.ToString("dd/MM/yyyy");
                query = Wherecondition("day", ngay, null, null, null);
            }
            else
            {
                query = Wherecondition(type, date, month, quarter, year);
            }
            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                List <contentreportWater> listdata = db.Database.SqlQuery <contentreportWater>(query).ToList();
                if (listdata != null)
                {
                    double totaltieuhao = 0; double totalsanluong = 0; double totalgio = 0;
                    foreach (var item in listdata)
                    {
                        totaltieuhao     += item.LuongTieuThu;
                        totalsanluong    += item.SanLuong;
                        totalgio         += item.GioHoatDong;
                        item.LuongTieuThu = Math.Round(item.LuongTieuThu, 1);
                    }
                    ViewBag.TieuHao     = totaltieuhao;
                    ViewBag.SanLuong    = totalsanluong;
                    ViewBag.GioHoatDong = totalgio;
                }
            }

            return(View("/Views/CDVT/Report/WaterReport.cshtml"));
        }
Esempio n. 26
0
        public ActionResult listDepartment()
        {
            var department_id   = Request["department_id"].ToString().Trim();
            var department_name = Request["department_name"].ToString().Trim();
            var department_type = Request["department_type"].ToString().Trim();

            using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
            {
                db.Configuration.LazyLoadingEnabled = false;
                int    start          = Convert.ToInt32(Request["start"]);
                int    length         = Convert.ToInt32(Request["length"]);
                string searchValue    = Request["search[value]"];
                string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
                string sortDirection  = Request["order[0][dir]"];
                //List<Department> hs_nv = new List<Department>();
                var hs_nv = db.Departments.Where(x => x.department_id.Contains(department_id) && x.department_name.Contains(department_name) && x.department_type.Contains(department_type))
                            .OrderBy(sortColumnName + " " + sortDirection).Skip(start).Take(length).ToList();

                int totalrows = db.Departments.Where(x => x.department_id.Contains(department_id) && x.department_name.Contains(department_name) && x.department_type.Contains(department_type)).Count();
                var dataJson  = Json(new { success = true, data = hs_nv, draw = Request["draw"], recordsTotal = totalrows, recordsFiltered = totalrows }, JsonRequestBehavior.AllowGet);

                //string dataSerialize = new JavaScriptSerializer().Serialize(dataJson.Data);

                return(dataJson);
            }
        }
Esempio n. 27
0
        public ActionResult getDataHistoryWork(string id)
        {
            int    start          = Convert.ToInt32(Request["start"]);
            int    length         = Convert.ToInt32(Request["length"]);
            string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
            string sortDirection  = Request["order[0][dir]"];

            try
            {
                using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
                {
                    db.Configuration.LazyLoadingEnabled = false;
                    List <GetWorkHistory_Result> listDiemDanhById = db.Database.SqlQuery <GetWorkHistory_Result>
                                                                        (@"[Manufacturing].GetWorkHistory {0}, {1}, {2}, {3}, {4}",
                                                                        id, sortDirection, sortColumnName, start, length).ToList();
                    int totalrows = db.Database.SqlQuery <int>
                                        (@"[Manufacturing].GetCountWorkHistory {0}", id).FirstOrDefault();

                    return(Json(new { success = true, data = listDiemDanhById, draw = Request["draw"], recordsTotal = totalrows, recordsFiltered = totalrows }, JsonRequestBehavior.AllowGet));;
                }
            }
            catch (Exception e)
            {
                return(Json(new { data = "", draw = Request["draw"], recordsTotal = 0, recordsFiltered = 0 }, JsonRequestBehavior.AllowGet));;
            }
        }
Esempio n. 28
0
        public ActionResult AddNewDepartment(string departmentJson)
        {
            dynamic dataJson = JObject.Parse(departmentJson);
            string  mpb      = dataJson.mpb;
            string  tpb      = dataJson.tpb;
            string  lpb      = dataJson.lpb;
            bool    isInside = Convert.ToBoolean(dataJson.isInside);

            Department department = new Department {
                department_id = mpb, department_name = tpb, department_type = lpb, isInside = isInside
            };

            try
            {
                using (QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities())
                {
                    var pb = db.Departments.Add(department);
                    db.SaveChanges();
                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 29
0
        public JsonResult NotYetDelete(string id)
        {
            QuangHanhManufacturingEntities db = new QuangHanhManufacturingEntities();

            db.Configuration.LazyLoadingEnabled = false;
            using (DbContextTransaction dbct = db.Database.BeginTransaction())
            {
                try
                {
                    List <Termination> list     = db.Terminations.Where(x => x.decision_id + "" == id).ToList();
                    string             listMaNV = "";
                    foreach (var MaNV in list)
                    {
                        listMaNV += "'" + MaNV.employee_id + "'" + ",";
                    }
                    listMaNV = listMaNV.Substring(0, listMaNV.Length - 1);
                    string query = @"update HumanResources.Employee set 
                        current_status_id = 1 where employee_id in(" + listMaNV + ") " +
                                   "delete from HumanResources.Termination where decision_id = @id " +
                                   "delete from HumanResources.Decision where decision_id = @id";
                    db.Database.ExecuteSqlCommand(query, new SqlParameter("id", id));
                    db.SaveChanges();
                    dbct.Commit();
                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception e)
                {
                    dbct.Rollback();
                    return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Esempio n. 30
0
        public ActionResult Summary(string SupplyName, string MonthPicked)
        {
            QuangHanhManufacturingEntities context = new QuangHanhManufacturingEntities();

            TonghopVattuSearchModelView search = new TonghopVattuSearchModelView
            {
                SupplyName  = SupplyName.Trim(),
                MonthPicked = MonthPicked.Trim()
            };
            int    start          = Convert.ToInt32(Request["start"]);
            int    length         = Convert.ToInt32(Request["length"]);
            string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
            string sortDirection  = Request["order[0][dir]"];

            search.MonthPicked = string.IsNullOrWhiteSpace(search.MonthPicked) ? "Tháng" + " " + DateTime.Now.Month + " " + @DateTime.Now.Year : search.MonthPicked;

            search.SupplyName = string.IsNullOrWhiteSpace(search.SupplyName) ? string.Empty : search.SupplyName;
            IList <TonghopvattuSummaryModelView> summary = _repository.GetSummary(search, sortColumnName, sortDirection, start, length);

            int recordsTotal    = _repository.CountSummary(search);
            int recordsFiltered = recordsTotal;

            return(Json(new
            {
                success = true,
                data = summary,

                recordsTotal,
                recordsFiltered
            }, JsonRequestBehavior.AllowGet));
        }