Beispiel #1
0
        public ActionResult Authorize(BI_USER userModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(userModel));
            }

            using (TKTDSXEntities db = new TKTDSXEntities())
            {
                string strInput = userModel.Password.Trim();

                string decryptPass = CryptorEngine.Encrypt(strInput, true);

                var userDetails = db.BI_USER.Where(x => x.MANDT == "900" && x.SYSID == "P01" &&
                                                   x.Username == userModel.Username && x.Password == decryptPass).FirstOrDefault();
                if (userDetails == null)
                {
                    ModelState.AddModelError("", "Sign failed, please check input again.");

                    return(View("Index", userModel));
                }
                else
                {
                    Session["Username"] = userDetails;
                    return(RedirectToAction("Index", "Liveboard"));
                }
            }
        }
Beispiel #2
0
        public ActionResult Login(ZEMP_USER account)
        {
            if (!ModelState.IsValid)
            {
                return(View(account));
            }

            using (TKTDSXEntities db = new TKTDSXEntities())
            {
                string strInput = account.Password.Trim();

                string decryptPass = CryptorEngine.Encrypt(strInput, true);

                var userDetails = db.ZEMP_USER.Where(x => x.SystemId == CommonHeader.defaultSystemId &&
                                                     x.Username == account.Username && x.Password == decryptPass).FirstOrDefault();
                if (userDetails == null)
                {
                    ModelState.AddModelError("", "Sign failed, please check input again.");

                    return(View("Index", account));
                }
                else
                {
                    Session[CommonHeader.ctlAccount] = userDetails;
                    return(RedirectToAction("Index", "Liveboard"));
                }
            }
        }
        public List <SelectListItem> GetListCongDoan(string sSystemId, string sLastCongDoan)
        {
            List <SelectListItem> listCongDoan = new List <SelectListItem>();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                try
                {
                    var  listRaw  = dc.GetCongDoanLiveboard(sSystemId).ToList <SelectListReturn>();
                    bool isSelect = false;

                    if (sLastCongDoan == null)
                    {
                        listCongDoan.Add(new SelectListItem()
                        {
                            Text = CommonHeader.CongDoanAllText, Value = CommonHeader.CongDoanAllValue, Selected = true
                        });
                    }
                    else
                    {
                        listCongDoan.Add(new SelectListItem()
                        {
                            Text = CommonHeader.CongDoanAllText, Value = CommonHeader.CongDoanAllValue, Selected = false
                        });
                    }

                    for (int i = 0; i < listRaw.Count; i++)
                    {
                        if (listRaw[i].value == sLastCongDoan)
                        {
                            isSelect = true;
                        }
                        else
                        {
                            isSelect = false;
                        }

                        listCongDoan.Add(new SelectListItem()
                        {
                            Text = listRaw[i].text, Value = listRaw[i].value, Selected = isSelect
                        });
                    }
                }
                catch (Exception ex)
                {
                    ZEMP_LOG zlog = new ZEMP_LOG()
                    {
                        Ngay           = DateTime.Now,
                        LogKey         = "GetCongDoanLiveboard",
                        LogDescription = string.Format("Exeption Msg: {0} ,SystemId: {1}", ex.Message, sSystemId)
                    };
                    dc.ZEMP_LOG.Add(zlog);
                    dc.SaveChanges();
                }
            }
            return(listCongDoan);
        }
Beispiel #4
0
        public List <SelectListItem> GetListCapDoByUsername(ZEMP_USER account)
        {
            bool isSelect = false;
            List <SelectListItem> selectList = new List <SelectListItem>();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                try
                {
                    var listRaw = dc.GetListCapDo(account.SystemId, account.Username).ToList <SelectListReturn>();

                    for (int i = 0; i < listRaw.Count; i++)
                    {
                        if (account.LastCapDo != "")
                        {
                            if (listRaw[i].value == account.LastCapDo)
                            {
                                isSelect = true;
                            }
                            else
                            {
                                isSelect = false;
                            }
                        }
                        else
                        {
                            if (i == 0)
                            {
                                isSelect = true;
                            }
                            else
                            {
                                isSelect = false;
                            }
                        }
                        selectList.Add(new SelectListItem()
                        {
                            Text = listRaw[i].text, Value = listRaw[i].value, Selected = isSelect
                        });
                    }
                }
                catch (Exception ex)
                {
                    ZEMP_LOG zlog = new ZEMP_LOG()
                    {
                        Ngay           = DateTime.Now,
                        LogKey         = "GetListCapDoByUsername",
                        LogDescription = string.Format("Exeption Msg: {0} , Username: {1} , LastCapDo: {2}",
                                                       ex.Message, account.Username, account.LastCapDo)
                    };
                    dc.ZEMP_LOG.Add(zlog);
                    dc.SaveChanges();
                }
            }
            return(selectList);
        }
        public List <SelectListItem> GetModeView(ZEMP_USER account)
        {
            List <SelectListItem> listMode = new List <SelectListItem>();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                try
                {
                    var  listRaw  = dc.GetModeView(account.SystemId).ToList <SelectListReturn>();
                    bool isSelect = false;
                    for (int i = 0; i < listRaw.Count; i++)
                    {
                        isSelect = false;
                        if (account.LastMode == null)
                        {
                            if (i == 0)
                            {
                                isSelect = true;
                            }
                            else
                            {
                                isSelect = false;
                            }
                        }
                        else
                        {
                            if (account.LastMode == listRaw[i].value)
                            {
                                isSelect = true;
                            }
                            else
                            {
                                isSelect = false;
                            }
                        }

                        listMode.Add(new SelectListItem()
                        {
                            Value = listRaw[i].value, Text = listRaw[i].text, Selected = isSelect
                        });
                    }
                }
                catch (Exception ex)
                {
                    ZEMP_LOG zlog = new ZEMP_LOG()
                    {
                        Ngay           = DateTime.Now,
                        LogKey         = "GetModeView",
                        LogDescription = string.Format("Exeption Msg: {0} ,SystemId: {1}", ex.Message, account.SystemId)
                    };
                    dc.ZEMP_LOG.Add(zlog);
                    dc.SaveChanges();
                }
            }
            return(listMode);
        }
Beispiel #6
0
 private List<ListCongDoan> getCongDoanKeHoachThucHien(FilterCondition f)
 {
     List<ListCongDoan> listCd = new List<ListCongDoan>();
     using(TKTDSXEntities dc = new TKTDSXEntities() )
     {
         listCd = dc.GetCongDoanKhTh(f.SystemId, f.SelectedCapDo, f.SelectedGiaTriCapDo,
                         f.SelectedCongDoan, f.sDateFrom, f.sDateTo).ToList<ListCongDoan>();
     }
     return listCd;
 }
        public string GetPhanQuyen(ref FilterCondition filter, ZEMP_USER account)
        {
            string     strResult = CommonHeader.ResultOK;
            AccountDTO accDto    = new AccountDTO();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                filter.ListCapDo = accDto.GetListCapDoByUsername(account);

                foreach (var item in  filter.ListCapDo)
                {
                    if (item.Selected)
                    {
                        filter.SelectedCapDo = item.Value;
                        break;
                    }
                }
                if (filter.ListCapDo.Count() == 0)
                {
                    strResult = "Chưa được phân quyền";
                }

                //Get list gia tri cap do theo selected cap do
                filter.ListGiaTriCapDo = accDto.GetListGiaTriCapDo(account, filter.SelectedCapDo);
                foreach (var item in filter.ListGiaTriCapDo)
                {
                    if (item.Selected)
                    {
                        filter.SelectedGiaTriCapDo = item.Value;
                        break;
                    }
                }

                LiveboardDTO liveboard = new LiveboardDTO();
                //Get list cong doan
                filter.ListCongDoan = liveboard.GetListCongDoan(account.SystemId, account.LastCongDoan);
                foreach (var item in filter.ListCongDoan)
                {
                    if (item.Selected)
                    {
                        filter.SelectedCongDoan = item.Value;
                    }
                }
                filter.ListModeView = liveboard.GetModeView(account);
                foreach (var item in filter.ListModeView)
                {
                    if (item.Selected)
                    {
                        filter.SelectedMode = item.Value;
                    }
                }
                return(strResult);
            }
        }
Beispiel #8
0
        // GET: Liveboard
        public ActionResult Index([Bind(Include = "SelectedMode,SelectedCapdo,SelectedGiaTriCapDo,SelectedCongDoan")] FilterCoditionModel FilterCodition)
        {
            var CurrentUser = Session["Username"] as BI_USER;

            if (CurrentUser == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            string strResult = String.Empty;

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                CommonModel cm = new CommonModel();

                try
                {
                    //get user login
                    FilterCodition.MANDT = CurrentUser.MANDT;
                    FilterCodition.SYSID = CurrentUser.SYSID;

                    //add mode view


                    //get data of current date
                    FilterCodition.DateFrom = DateTime.Now;
                    FilterCodition.DateTo   = DateTime.Now;

                    strResult                   = cm.GetPhanQuyen(ref FilterCodition, CurrentUser.Username);
                    ViewBag.SelectedCapDo       = FilterCodition.ListCapDo;
                    ViewBag.SelectedGiaTriCapDo = FilterCodition.ListGiaTriCapDo;
                    ViewBag.GiatriCapDo         = FilterCodition.SelectedGiaTriCapDo;

                    //lay danh sach cong doan
                    cm.GetCongDoanAll(ref FilterCodition);

                    ViewBag.SelectedCongDoan = FilterCodition.ListCongDoan;

                    cm.getModeView(ref FilterCodition);
                    ViewBag.SelectedMode = FilterCodition.ListModeView;

                    return(View("Index", FilterCodition));
                }
                catch (Exception ex)
                {
                    ViewBag.MessagePQ = "Chưa được cấp quyền" + ex.Message;
                    return(View());
                }
            }
        }
Beispiel #9
0
        private List<KHTHReturn> GetKeHoachThucHien(FilterCondition filter)
        {
            List<KHTHReturn> listKHTH = new List<KHTHReturn>();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                listKHTH = dc.GetKeHoachThucHien(filter.SystemId,
                                            filter.SelectedCapDo,
                                            filter.SelectedGiaTriCapDo,
                                            filter.SelectedCongDoan,
                                            filter.sDateFrom,
                                            filter.sDateTo).ToList<KHTHReturn>();
            }

            return listKHTH;
        }
        public ArrayList GetKeHoachThucHien(FilterCondition filter)
        {
            ArrayList listKhTh = new ArrayList();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                string dtFrom = string.Format("{0}-{1}-{2}", filter.DateFrom.Year, filter.DateFrom.Month, filter.DateFrom.Day);
                string dtTo   = string.Format("{0}-{1}-{2}", filter.DateFrom.Year, filter.DateFrom.Month, filter.DateFrom.Day);
                try
                {
                    var listRaw = dc.GetKeHoachThucHien(filter.SystemId, filter.SelectedCapDo, filter.SelectedGiaTriCapDo,
                                                        filter.SelectedCongDoan, dtFrom, dtTo).ToList <KHTHReturn>();
                    //Header
                    ArrayList lineHeader = new ArrayList();
                    lineHeader.Add("Data");
                    for (int i = 0; i < listRaw.Count; i++)
                    {
                        lineHeader.Add(listRaw[i].CONGDOAN.ToString());
                    }
                    listKhTh.Add(lineHeader);

                    //KeHoach
                    ArrayList lineKeHoach = new ArrayList();
                    lineKeHoach.Add("KeHoach");
                    for (int y = 0; y < listRaw.Count; y++)
                    {
                        lineKeHoach.Add(listRaw[y].KEHOACH.ToString());
                    }
                    listKhTh.Add(lineKeHoach);

                    //ThucHien
                    ArrayList lineThucHien = new ArrayList();
                    lineThucHien.Add("ThucHien");
                    for (int y = 0; y < listRaw.Count; y++)
                    {
                        lineThucHien.Add(listRaw[y].THUCHIEN.ToString());
                    }
                    listKhTh.Add(lineThucHien);
                }
                catch
                {
                    //do nothing
                }
            }
            return(listKhTh);
        }
Beispiel #11
0
 private List<ThongKeLaoDong> GetThongKeLaoDong(FilterCondition f)
 {
     var listLaoDong = new List<ThongKeLaoDong>();
     using (TKTDSXEntities dc = new TKTDSXEntities())
     {
         try
         {
             listLaoDong = dc.GetThongKeLaoDong(f.SystemId, f.SelectedCapDo,
                         f.SelectedGiaTriCapDo, f.SelectedCongDoan, f.sDateFrom, f.sDateTo).ToList<ThongKeLaoDong>();
         }
         catch (Exception ex)
         {
             Console.Write(ex.Message);
         }
         return listLaoDong;
     }
 } //end function - GetThongKeLaoDong
Beispiel #12
0
 private List<ChiPhiSanXuat> GetChiPhiSanXuat(FilterCondition f)
 {
     var listChiPhi = new List<ChiPhiSanXuat>();
     using (TKTDSXEntities dc = new TKTDSXEntities())
     {
         try
         {
             listChiPhi = dc.GETCHIPHISANXUAT(f.SystemId,
                 f.SelectedCapDo, f.SelectedGiaTriCapDo, f.SelectedCongDoan,
                 f.sDateFrom, f.sDateTo).ToList<ChiPhiSanXuat>();
         }
         catch (Exception ex)
         {
             Console.Write(ex.Message);
         }
     }
         return listChiPhi;
 }
Beispiel #13
0
        private List<CountStatus> CountStatusChuyen(FilterCondition f)
        {
            var listCountStatus = new List<CountStatus>();
            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                try
                {
                    listCountStatus = dc.CountTrangThaiChuyen(f.SystemId, f.SelectedCapDo,
                        f.SelectedGiaTriCapDo, f.SelectedCongDoan, f.sDateFrom, f.sDateTo).ToList<CountStatus>();
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }

            }
            return listCountStatus;
        }
Beispiel #14
0
        public ActionResult GetListData(string level, string capdo, string giaTriCapdo, string congDoan, string sStyle)
        {
            FilterCoditionModel filter = new FilterCoditionModel()
            {
                MANDT               = "900",
                SYSID               = "P01",
                SelectedMode        = level,
                SelectedCapDo       = capdo,
                SelectedGiaTriCapDo = giaTriCapdo,
                SelectedCongDoan    = congDoan
            };

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                var         CurrentUser = Session["Username"] as BI_USER;
                CommonModel cm          = new CommonModel();
                //Mode xem
                if (filter.SelectedMode == null)
                {
                    filter.SelectedMode = "CHUYEN";
                }
                List <SanLuongOnline> slOnline = cm.GetSanLuongOnline(filter, CurrentUser.Username);
                ViewData["SL_Online"] = slOnline;
            }

            //asign style for table
            switch (sStyle)
            {
            case "Default":
                ViewBag.ClassName = "tablesorter-default";
                break;

            case "Blue":
                ViewBag.ClassName = "tablesorter-blue";
                break;

            case "Dark":
                ViewBag.ClassName = "tablesorter-dark";
                break;
            }

            return(PartialView(filter));
        }
Beispiel #15
0
        public ActionResult GetSub(string CapDoID)
        {
            TKTDSXEntities dc          = new TKTDSXEntities();
            var            CurrentUser = Session["Username"] as BI_USER;

            List <BI_PHAN_QUYEN> listPQ = dc.BI_PHAN_QUYEN.Where(p => p.CapDo == CapDoID && p.Username == CurrentUser.Username).ToList();

            List <SelectListItem> items = new List <SelectListItem>();

            foreach (BI_PHAN_QUYEN item in listPQ)
            {
                items.Add(new SelectListItem()
                {
                    Text = item.DGGiaTri, Value = item.GiaTri
                });
            }

            // you may replace the above code with data reading from database based on the id

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
        public List <SanLuongOnline> GetSanLuongOnline(string sModeView, string sCapDo, string sGiaTriCapDo, string sCongDoan, string sNgay)
        {
            var ListSanLuong = new List <SanLuongOnline>();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                List <SanLuongOnlineReturn> listRaw = dc.GetSanLuongOnline(CommonHeader.defaultSystemId, sModeView, sCapDo, sGiaTriCapDo, sCongDoan, sNgay).ToList <SanLuongOnlineReturn>();
                foreach (var item in listRaw)
                {
                    var itemSanLuong = new SanLuongOnline()
                    {
                        BoPhan         = item.BoPhan,
                        CongDoan       = item.TenCongDoan,
                        SoLuongLaoDong = int.Parse(item.SoLuongLD.ToString()),
                        NangSuat       = double.Parse(item.NangSuat.ToString()),
                        GioLamViec     = double.Parse(item.GioLamViec.ToString()),
                        KeHoachGio     = int.Parse(item.KeHoachGio.ToString()),
                        KeHoachNgay    = int.Parse(item.KeHoachNgay.ToString()),
                        ThucHien       = int.Parse(item.ThucHienNgay.ToString()),
                        ChenhLech      = int.Parse(item.ChenhLech.ToString()),
                        DatSanLuong    = double.Parse(item.DatKeHoach.ToString()),
                        Truoc8h        = int.Parse(item.Truoc8h.ToString()),
                        Gio08          = int.Parse(item.Gio08.ToString()),
                        Gio09          = int.Parse(item.Gio09.ToString()),
                        Gio10          = int.Parse(item.Gio10.ToString()),
                        Gio11          = int.Parse(item.Gio11.ToString()),
                        Gio12          = int.Parse(item.Gio12.ToString()),
                        Gio13          = int.Parse(item.Gio13.ToString()),
                        Gio14          = int.Parse(item.Gio14.ToString()),
                        Gio15          = int.Parse(item.Gio15.ToString()),
                        Gio16          = int.Parse(item.Gio16.ToString()),
                        Gio17          = int.Parse(item.Gio17.ToString()),
                        Gio18          = int.Parse(item.Gio18.ToString()),
                        Sau18          = int.Parse(item.Sau18h.ToString())
                    };

                    if (item.IsNoColor.Trim() == "X")
                    {
                        itemSanLuong.isColor = false;
                    }
                    else
                    {
                        itemSanLuong.isColor = true;
                    }

                    //Set color for text
                    if (itemSanLuong.isColor) // Co to mau
                    {
                        if (itemSanLuong.DatSanLuong < 95)
                        {
                            itemSanLuong.sColorText = CommonHeader.CSS_TEXT_RED;
                        }
                        else if ((itemSanLuong.DatSanLuong >= 95) && (itemSanLuong.DatSanLuong < 100))
                        {
                            itemSanLuong.sColorText = CommonHeader.CSS_TEXT_YELLOW;
                        }
                        else
                        {
                            itemSanLuong.sColorText = CommonHeader.CSS_TEXT_GREEN;
                        }
                    }
                    else // Khong to mau
                    {
                        itemSanLuong.sColorText = "";
                    }
                    ListSanLuong.Add(itemSanLuong);
                }
            }
            return(ListSanLuong);
        }
Beispiel #17
0
        public ActionResult TestDashboard([Bind(Include = "SelectedCapdo,SelectedGiaTriCapDo,SelectedCongDoan,DateFrom,DateTo")] FilterCoditionModel FilterCodition)
        {
            var CurrentUser = Session["Username"] as BI_USER;

            if (CurrentUser == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            string strResult = String.Empty;

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                CommonModel cm = new CommonModel();

                try
                {
                    FilterCodition.MANDT = CurrentUser.MANDT;
                    FilterCodition.SYSID = CurrentUser.SYSID;

                    strResult = cm.GetPhanQuyen(ref FilterCodition, CurrentUser.Username);

                    cm.GetCongDoanDauRa(ref FilterCodition);

                    ViewBag.SelectedCapDo       = FilterCodition.ListCapDo;
                    ViewBag.SelectedGiaTriCapDo = FilterCodition.ListGiaTriCapDo;
                    ViewBag.SelectedCongDoan    = FilterCodition.ListCongDoan;

                    if (FilterCodition.DateFrom > FilterCodition.DateTo)
                    {
                        ViewBag.MessagePQ = "Ngày bắt đầu không được lớn hơn ngày kết thúc";
                        return(View("TestDashboard", FilterCodition));
                    }

                    ViewBag.GiatriCapDo = FilterCodition.SelectedGiaTriCapDo;

                    ArrayList chartSanLuong = new ArrayList();
                    ArrayList StatusChart   = new ArrayList();

                    List <TrangThaiChuyen> ListDataStatus = new List <TrangThaiChuyen>();

                    //Chart San Luong
                    List <SanLuongNgay> sln = cm.GetSanLuongNgay(FilterCodition, ref chartSanLuong, ref ListDataStatus);
                    string strData          = JsonConvert.SerializeObject(chartSanLuong, Formatting.None);
                    ViewBag.DataChartSLNgay = new HtmlString(strData);
                    sln.OrderByDescending(o => o.Ngay);
                    ViewData["SanLuongNgay"] = sln;

                    //Chart Status
                    ArrayList HeaderStatus = new ArrayList();
                    HeaderStatus.Add((object)string.Format("{0}", "Ngay"));
                    HeaderStatus.Add((object)string.Format("{0}", "< 95%"));
                    HeaderStatus.Add((object)string.Format("{0}", "95-100%"));
                    HeaderStatus.Add((object)string.Format("{0}", "> 100%"));
                    //HeaderStatus.Add((object)string.Format("{0}", "Khác"));
                    StatusChart.Add(HeaderStatus);

                    foreach (TrangThaiChuyen statusCH in ListDataStatus)
                    {
                        ArrayList dataChart = new ArrayList();
                        dataChart.Add(statusCH.Ngay.ToShortDateString());
                        dataChart.Add(statusCH.redStatus);
                        dataChart.Add(statusCH.yellowStatus);
                        dataChart.Add(statusCH.greenStatus);
                        //dataChart.Add(statusCH.otherStatus);
                        StatusChart.Add(dataChart);
                    }

                    strData = string.Empty;
                    strData = JsonConvert.SerializeObject(StatusChart, Formatting.None);
                    ViewBag.DataChartStatus = new HtmlString(strData);

                    ViewData["StatusChuyen"] = ListDataStatus;


                    // Lay thong di di lam / nghi phep
                    List <ThongKeLaoDong> listTKLD = new List <ThongKeLaoDong>();
                    listTKLD = cm.GetThongKeLaoDong(FilterCodition);
                    //create array list so luong lao dong --> chart
                    ArrayList TkldChart  = new ArrayList();
                    ArrayList tkldHeader = new ArrayList();
                    tkldHeader.Add((object)string.Format("{0}", "Ngày"));
                    tkldHeader.Add((object)string.Format("{0}", "Tổng LĐ"));
                    tkldHeader.Add((object)string.Format("{0}", "% Vắng"));

                    TkldChart.Add(tkldHeader);
                    foreach (ThongKeLaoDong tkItem in listTKLD)
                    {
                        ArrayList item = new ArrayList();
                        item.Add(tkItem.Ngay.ToShortDateString());

                        double ptVang = Math.Round((double)tkItem.SoLuongNghi / (double)tkItem.TongSoLuong * 100, 1);

                        item.Add(tkItem.TongSoLuong);
                        item.Add(ptVang);
                        TkldChart.Add(item);
                    }
                    strData = JsonConvert.SerializeObject(TkldChart, Formatting.None);
                    ViewData["ThongKeLD"] = listTKLD;
                    ViewBag.DataTkld      = new HtmlString(strData);


                    //********************Get Nang Suat lao Dong **************************
                    ArrayList chartNangSuat = new ArrayList();
                    List <NangSuatLaoDong> listNangSuatTheoSL = cm.GetNangSuatSanLuong(FilterCodition, ref chartNangSuat);
                    ViewData["NSLD"] = listNangSuatTheoSL;
                    strData          = JsonConvert.SerializeObject(chartNangSuat, Formatting.None);
                    ViewBag.DataNsld = new HtmlString(strData);
                    //********************Get Nang Suat lao Dong **************************



                    //*********TINH TOAN GIA THANH PHAN XUONG********************
                    ArrayList chartGiaThanhPhanXuong  = new ArrayList();
                    List <GiaThanhPhanXuong> listGtpx = cm.GetGiaThanhPhanXuong(FilterCodition);
                    ViewData["GTPX"] = listGtpx;
                    strData          = JsonConvert.SerializeObject(chartGiaThanhPhanXuong, Formatting.None);
                    ViewBag.DataGtpx = new HtmlString(strData);

                    ArrayList CommomArray = new ArrayList();
                    bool      iFound      = false;
                    for (int i = 0; i < chartSanLuong.Count; i++)
                    {
                        ArrayList lineCommon = new ArrayList();
                        if (i == 0) //Header
                        {
                            lineCommon.Add((object)string.Format("{0}", "Ngày"));

                            ArrayList headerSanLuong = (ArrayList)chartSanLuong[0];

                            //add header san luong
                            for (int s = 1; s < headerSanLuong.Count; s++)
                            {
                                lineCommon.Add((object)string.Format("SL-{0}", headerSanLuong[s]));
                            }

                            //add header thong ke chuyen
                            ArrayList headerStatus = (ArrayList)StatusChart[0];
                            for (int s = 1; s < headerStatus.Count; s++)
                            {
                                lineCommon.Add((object)string.Format("ST-{0}", headerStatus[s]));
                            }

                            //add header nang suat lao dong
                            ArrayList headerNS = (ArrayList)chartNangSuat[0];
                            for (int n = 1; n < headerNS.Count; n++)
                            {
                                lineCommon.Add((object)string.Format("NS-{0}", headerNS[n]));
                            }

                            //add header thong ke lao dong
                            ArrayList headerTkld = (ArrayList)TkldChart[0];
                            for (int l = 1; l < headerTkld.Count; l++)
                            {
                                lineCommon.Add((object)string.Format("LD-{0}", headerTkld[l]));
                            }
                        }
                        else //line item
                        {
                            ArrayList lineSanLuong = (ArrayList)chartSanLuong[i];

                            //add line san luong
                            for (int s = 0; s < lineSanLuong.Count; s++)
                            {
                                lineCommon.Add((lineSanLuong[s]));
                            }

                            iFound = false;
                            //add line thong ke chuyen
                            for (int y = 1; y < StatusChart.Count; y++)
                            {
                                ArrayList lineStatus = (ArrayList)StatusChart[y];
                                if (lineCommon[0].ToString() != lineStatus[0].ToString())
                                {
                                    continue;
                                }
                                iFound = true;
                                for (int s = 1; s < lineStatus.Count; s++)
                                {
                                    lineCommon.Add(lineStatus[s]);
                                }
                                break;
                            }

                            if (!iFound)
                            {
                                ArrayList lineStatus = (ArrayList)StatusChart[0];
                                for (int s = 1; s < lineStatus.Count; s++)
                                {
                                    lineCommon.Add(0);
                                }
                            }

                            iFound = false;
                            //add line nang suat
                            for (int y = 1; y < chartNangSuat.Count; y++)
                            {
                                ArrayList line = (ArrayList)chartNangSuat[y];
                                if (lineCommon[0].ToString() != line[0].ToString())
                                {
                                    continue;
                                }
                                iFound = true;
                                for (int n = 1; n < line.Count; n++)
                                {
                                    lineCommon.Add(line[n]);
                                }
                                break;
                            }

                            if (!iFound)
                            {
                                ArrayList line = (ArrayList)chartNangSuat[0];
                                for (int s = 1; s < line.Count; s++)
                                {
                                    lineCommon.Add(0);
                                }
                            }

                            //add line thong ke lao dong
                            iFound = false;
                            for (int y = 1; y < TkldChart.Count; y++)
                            {
                                ArrayList line = (ArrayList)TkldChart[y];
                                if (lineCommon[0].ToString() != line[0].ToString())
                                {
                                    continue;
                                }
                                iFound = true;
                                for (int l = 1; l < line.Count; l++)
                                {
                                    lineCommon.Add(line[l]);
                                }
                                break;
                            }
                            if (!iFound)
                            {
                                ArrayList line = (ArrayList)TkldChart[0];
                                for (int s = 1; s < line.Count; s++)
                                {
                                    lineCommon.Add(0);
                                }
                            }
                        }
                        CommomArray.Add(lineCommon);
                    }

                    strData            = JsonConvert.SerializeObject(CommomArray, Formatting.None);
                    ViewBag.DataCommon = new HtmlString(strData);

                    //*********TINH TOAN GIA THANH PHAN XUONG********************


                    if (FilterCodition.SelectedCapDo == "NGANH")
                    {
                        ViewBag.CapDo = "Ngành";
                    }
                    else if (FilterCodition.SelectedCapDo == "KHVUC")
                    {
                        ViewBag.CapDo = "Khu Vực";
                    }
                    else if (FilterCodition.SelectedCapDo == "WRKCT")
                    {
                        ViewBag.CapDo = "Work Center";
                    }
                    return(View("TestDashboard", FilterCodition));
                }
                catch (Exception ex)
                {
                    ViewData["SLCH"]  = null;
                    ViewBag.MessagePQ = "Chưa được cấp quyền" + ex.Message;
                    return(View("TestDashboard"));
                }
            }
        }
Beispiel #18
0
        public ActionResult Index([Bind(Include = "SelectedCapdo,SelectedGiaTriCapDo,SelectedCongDoan,DateFrom,DateTo")] FilterCoditionModel FilterCodition)
        {
            var CurrentUser = Session["Username"] as BI_USER;

            if (CurrentUser == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            string strResult = String.Empty;

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                CommonModel cm = new CommonModel();

                try
                {
                    FilterCodition.MANDT = CurrentUser.MANDT;
                    FilterCodition.SYSID = CurrentUser.SYSID;

                    strResult = cm.GetPhanQuyen(ref FilterCodition, CurrentUser.Username);

                    cm.GetCongDoanDauRa(ref FilterCodition);

                    ViewBag.SelectedCapDo       = FilterCodition.ListCapDo;
                    ViewBag.SelectedGiaTriCapDo = FilterCodition.ListGiaTriCapDo;
                    ViewBag.SelectedCongDoan    = FilterCodition.ListCongDoan;

                    if (FilterCodition.DateFrom > FilterCodition.DateTo)
                    {
                        ViewBag.MessagePQ = "Ngày bắt đầu không được lớn hơn ngày kết thúc";
                        return(View("TestDashboard", FilterCodition));
                    }

                    ViewBag.GiatriCapDo = FilterCodition.SelectedGiaTriCapDo;

                    ArrayList chartSanLuong = new ArrayList();
                    ArrayList StatusChart   = new ArrayList();

                    List <TrangThaiChuyen> ListDataStatus = new List <TrangThaiChuyen>();

                    //Chart San Luong
                    List <SanLuongNgay> sln = cm.GetSanLuongNgay(FilterCodition, ref chartSanLuong, ref ListDataStatus);
                    //string strData = JsonConvert.SerializeObject(chartSanLuong, Formatting.None);
                    //ViewBag.DataChartSLNgay = new HtmlString(strData);
                    sln.OrderByDescending(o => o.Ngay);
                    ViewData["SanLuongNgay"] = sln;

                    //Chart Status
                    ArrayList HeaderStatus = new ArrayList();
                    HeaderStatus.Add((object)string.Format("{0}", "Ngay"));
                    HeaderStatus.Add((object)string.Format("{0}", "< 95%"));
                    HeaderStatus.Add((object)string.Format("{0}", "95-100%"));
                    HeaderStatus.Add((object)string.Format("{0}", "> 100%"));
                    //HeaderStatus.Add((object)string.Format("{0}", "Khác"));
                    StatusChart.Add(HeaderStatus);

                    foreach (TrangThaiChuyen statusCH in ListDataStatus)
                    {
                        ArrayList dataChart = new ArrayList();
                        dataChart.Add(statusCH.Ngay.ToShortDateString());
                        dataChart.Add(statusCH.redStatus);
                        dataChart.Add(statusCH.yellowStatus);
                        dataChart.Add(statusCH.greenStatus);
                        //dataChart.Add(statusCH.otherStatus);
                        StatusChart.Add(dataChart);
                    }

                    //strData = string.Empty;
                    //strData = JsonConvert.SerializeObject(StatusChart, Formatting.None);
                    //ViewBag.DataChartStatus = new HtmlString(strData);

                    ViewData["StatusChuyen"] = ListDataStatus;


                    // Lay thong di di lam / nghi phep
                    List <ThongKeLaoDong> listTKLD = new List <ThongKeLaoDong>();
                    listTKLD = cm.GetThongKeLaoDong(FilterCodition);
                    //create array list so luong lao dong --> chart
                    ArrayList TkldChart  = new ArrayList();
                    ArrayList tkldHeader = new ArrayList();
                    tkldHeader.Add((object)string.Format("{0}", "Ngày"));
                    tkldHeader.Add((object)string.Format("{0}", "Tổng LĐ"));
                    tkldHeader.Add((object)string.Format("{0}", "% Vắng"));
                    TkldChart.Add(tkldHeader);
                    foreach (ThongKeLaoDong tkItem in listTKLD)
                    {
                        //DayOfWeek dayOfWeek = tkItem.Ngay.DayOfWeek;
                        //if (dayOfWeek == DayOfWeek.Sunday)
                        //{
                        //    continue;
                        //}
                        ArrayList item = new ArrayList();
                        item.Add(tkItem.Ngay.ToShortDateString());

                        double ptVang = Math.Round((double)tkItem.SoLuongNghi / (double)tkItem.TongSoLuong * 100, 1);

                        item.Add(tkItem.TongSoLuong);
                        item.Add(ptVang);
                        TkldChart.Add(item);
                    }
                    ViewData["ThongKeLD"] = listTKLD;
                    //strData = JsonConvert.SerializeObject(TkldChart, Formatting.None);
                    //ViewBag.DataTkld = new HtmlString(strData);


                    //********************Get Nang Suat lao Dong **************************
                    ArrayList chartNangSuat = new ArrayList();
                    List <NangSuatLaoDong> listNangSuatTheoSL = cm.GetNangSuatSanLuong(FilterCodition, ref chartNangSuat);
                    ViewData["NSLD"] = listNangSuatTheoSL;
                    //strData = JsonConvert.SerializeObject(chartNangSuat, Formatting.None);
                    //ViewBag.DataNsld = new HtmlString(strData);
                    //********************Get Nang Suat lao Dong **************************



                    //*********TINH TOAN GIA THANH PHAN XUONG********************
                    ArrayList chartGiaThanhPhanXuong  = new ArrayList();
                    List <GiaThanhPhanXuong> listGtpx = cm.GetGiaThanhPhanXuong(FilterCodition);


                    //Data for Chart Gia Thanh Phan Xuong
                    ArrayList headerGTPX = new ArrayList();
                    headerGTPX.Add("Công Đoạn");
                    headerGTPX.Add("Vật Tư");
                    headerGTPX.Add("Tài Sản");
                    headerGTPX.Add("Nhân Công");
                    chartGiaThanhPhanXuong.Add(headerGTPX);

                    //data for chart nang suat lao dong tong the
                    List <NangSuatTongThe> listNSTT = new List <NangSuatTongThe>();

                    if (FilterCodition.SelectedCongDoan != "ALL")
                    {
                        // Tính tổng giá trị
                        GiaThanhPhanXuong tongGTPX = new GiaThanhPhanXuong();
                        for (int i = 0; i < listGtpx.Count; i++)
                        {
                            tongGTPX.gtNhanCongKeHoach  += listGtpx[i].gtNhanCongKeHoach;
                            tongGTPX.gtVatTuKeHoach     += listGtpx[i].gtVatTuKeHoach;
                            tongGTPX.gtTaiSanKeHoach    += listGtpx[i].gtTaiSanKeHoach;
                            tongGTPX.gtNhanCongThucHien += listGtpx[i].gtNhanCongThucHien;
                            tongGTPX.gtVatTuThucHien    += listGtpx[i].gtVatTuThucHien;
                            tongGTPX.gtTaiSanThucHien   += listGtpx[i].gtTaiSanThucHien;
                        }


                        tongGTPX.ptNhanCongKeHoach = Math.Round(tongGTPX.gtNhanCongKeHoach / (tongGTPX.gtNhanCongKeHoach +
                                                                                              tongGTPX.gtVatTuKeHoach + tongGTPX.gtTaiSanKeHoach) * 100, 2);

                        tongGTPX.ptVatTuKeHoach = Math.Round(tongGTPX.gtVatTuKeHoach / (tongGTPX.gtNhanCongKeHoach +
                                                                                        tongGTPX.gtVatTuKeHoach + tongGTPX.gtTaiSanKeHoach) * 100, 2);

                        tongGTPX.ptTaiSanKeHoach = Math.Round(tongGTPX.gtTaiSanKeHoach / (tongGTPX.gtNhanCongKeHoach +
                                                                                          tongGTPX.gtVatTuKeHoach + tongGTPX.gtTaiSanKeHoach) * 100, 2);

                        tongGTPX.ptNhanCongThucHien = Math.Round(tongGTPX.gtNhanCongThucHien / (tongGTPX.gtNhanCongThucHien +
                                                                                                tongGTPX.gtVatTuThucHien + tongGTPX.gtTaiSanThucHien) * 100, 2);
                        tongGTPX.ptVatTuThucHien = Math.Round(tongGTPX.gtVatTuThucHien / (tongGTPX.gtNhanCongThucHien +
                                                                                          tongGTPX.gtVatTuThucHien + tongGTPX.gtTaiSanThucHien) * 100, 2);
                        tongGTPX.ptTaiSanThucHien = Math.Round(tongGTPX.gtTaiSanThucHien / (tongGTPX.gtNhanCongThucHien +
                                                                                            tongGTPX.gtVatTuThucHien + tongGTPX.gtTaiSanThucHien) * 100, 2);


                        //add row ke hoach
                        ArrayList lineKeHoach = new ArrayList();
                        lineKeHoach.Add(string.Format("KH-{0}", FilterCodition.SelectedCongDoan));
                        lineKeHoach.Add(tongGTPX.ptVatTuKeHoach);
                        lineKeHoach.Add(tongGTPX.ptTaiSanKeHoach);
                        lineKeHoach.Add(tongGTPX.ptNhanCongKeHoach);
                        //add line to list
                        chartGiaThanhPhanXuong.Add(lineKeHoach);

                        //add line thuc hien
                        ArrayList lineThucHien = new ArrayList();
                        lineThucHien.Add(string.Format("TH-{0}", FilterCodition.SelectedCongDoan));
                        lineThucHien.Add(tongGTPX.ptVatTuThucHien);
                        lineThucHien.Add(tongGTPX.ptTaiSanThucHien);
                        lineThucHien.Add(tongGTPX.ptNhanCongThucHien);
                        //add line to list
                        chartGiaThanhPhanXuong.Add(lineThucHien);

                        //tinh nhan cong binh quan
                        int    iCountLD = 0;
                        double iLDBQ    = 0;
                        double dNSTT    = 0;
                        double dTongNS  = 0;
                        foreach (NangSuatLaoDong nsld in listNangSuatTheoSL)
                        {
                            if (nsld.CongDoan != FilterCodition.SelectedCongDoan)
                            {
                                continue;
                            }
                            iLDBQ   += nsld.SoLuongLaoDong;
                            dTongNS += nsld.NangSuat;
                            iCountLD++;
                        }

                        if (iCountLD > 0)
                        {
                            iLDBQ   = iLDBQ / (double)iCountLD;
                            dTongNS = dTongNS / (double)iCountLD;
                            dNSTT   = Math.Round((Double)((tongGTPX.gtNhanCongThucHien + tongGTPX.gtVatTuThucHien + tongGTPX.gtTaiSanThucHien) / iLDBQ), 2);
                        }


                        NangSuatTongThe lineNSTT = new NangSuatTongThe();
                        lineNSTT.CongDoan       = FilterCodition.SelectedCongDoan;
                        lineNSTT.SoLuongLaoDong = Math.Round(iLDBQ, 0);
                        lineNSTT.ptChiPhiNc     = Math.Round(tongGTPX.ptNhanCongThucHien, 2);
                        lineNSTT.ptChiPhiVt     = Math.Round(tongGTPX.ptVatTuThucHien, 2);
                        lineNSTT.ptChiPhiTs     = Math.Round(tongGTPX.ptTaiSanThucHien, 2);
                        lineNSTT.NangSuatTT     = Math.Round(dNSTT, 2);
                        lineNSTT.NangSuatSL     = Math.Round(dTongNS, 2);
                        listNSTT.Add(lineNSTT);
                    }
                    else
                    {
                        foreach (SelectListItem cdoan in FilterCodition.ListCongDoan)
                        {
                            if (cdoan.Value == "ALL")
                            {
                                continue;
                            }
                            long iCount = 0;
                            GiaThanhPhanXuong tongGTPX = new GiaThanhPhanXuong();
                            for (int i = 0; i < listGtpx.Count; i++)
                            {
                                if (cdoan.Value != listGtpx[i].CongDoan)
                                {
                                    continue;
                                }
                                tongGTPX.gtNhanCongKeHoach  += listGtpx[i].gtNhanCongKeHoach;
                                tongGTPX.gtVatTuKeHoach     += listGtpx[i].gtVatTuKeHoach;
                                tongGTPX.gtTaiSanKeHoach    += listGtpx[i].gtTaiSanKeHoach;
                                tongGTPX.gtNhanCongThucHien += listGtpx[i].gtNhanCongThucHien;
                                tongGTPX.gtVatTuThucHien    += listGtpx[i].gtVatTuThucHien;
                                tongGTPX.gtTaiSanThucHien   += listGtpx[i].gtTaiSanThucHien;

                                iCount++;
                            }


                            tongGTPX.ptNhanCongKeHoach = Math.Round(tongGTPX.gtNhanCongKeHoach / (tongGTPX.gtNhanCongKeHoach +
                                                                                                  tongGTPX.gtVatTuKeHoach + tongGTPX.gtTaiSanKeHoach) * 100, 2);

                            tongGTPX.ptVatTuKeHoach = Math.Round(tongGTPX.gtVatTuKeHoach / (tongGTPX.gtNhanCongKeHoach +
                                                                                            tongGTPX.gtVatTuKeHoach + tongGTPX.gtTaiSanKeHoach) * 100, 2);

                            tongGTPX.ptTaiSanKeHoach = Math.Round(tongGTPX.gtTaiSanKeHoach / (tongGTPX.gtNhanCongKeHoach +
                                                                                              tongGTPX.gtVatTuKeHoach + tongGTPX.gtTaiSanKeHoach) * 100, 2);

                            tongGTPX.ptNhanCongThucHien = Math.Round(tongGTPX.gtNhanCongThucHien / (tongGTPX.gtNhanCongThucHien +
                                                                                                    tongGTPX.gtVatTuThucHien + tongGTPX.gtTaiSanThucHien) * 100, 2);
                            tongGTPX.ptVatTuThucHien = Math.Round(tongGTPX.gtVatTuThucHien / (tongGTPX.gtNhanCongThucHien +
                                                                                              tongGTPX.gtVatTuThucHien + tongGTPX.gtTaiSanThucHien) * 100, 2);
                            tongGTPX.ptTaiSanThucHien = Math.Round(tongGTPX.gtTaiSanThucHien / (tongGTPX.gtNhanCongThucHien +
                                                                                                tongGTPX.gtVatTuThucHien + tongGTPX.gtTaiSanThucHien) * 100, 2);

                            //add row ke hoach
                            ArrayList lineKeHoach = new ArrayList();
                            lineKeHoach.Add(string.Format("KH-{0}", cdoan.Value));
                            lineKeHoach.Add(tongGTPX.ptVatTuKeHoach);
                            lineKeHoach.Add(tongGTPX.ptTaiSanKeHoach);
                            lineKeHoach.Add(tongGTPX.ptNhanCongKeHoach);
                            //add line to list
                            chartGiaThanhPhanXuong.Add(lineKeHoach);

                            //add line thuc hien
                            ArrayList lineThucHien = new ArrayList();
                            lineThucHien.Add(string.Format("TH-{0}", cdoan.Value));
                            lineThucHien.Add(tongGTPX.ptVatTuThucHien);
                            lineThucHien.Add(tongGTPX.ptTaiSanThucHien);
                            lineThucHien.Add(tongGTPX.ptNhanCongThucHien);
                            //add line to list
                            chartGiaThanhPhanXuong.Add(lineThucHien);



                            //tinh nhan cong binh quan
                            int    iCountLD = 0;
                            double iLDBQ    = 0;
                            double dNSTT    = 0;
                            double dTongNS  = 0;
                            foreach (NangSuatLaoDong nsld in listNangSuatTheoSL)
                            {
                                if (nsld.CongDoan != cdoan.Value)
                                {
                                    continue;
                                }
                                iLDBQ   += nsld.SoLuongLaoDong;
                                dTongNS += nsld.NangSuat;
                                iCountLD++;
                            }

                            if (iCountLD > 0)
                            {
                                iLDBQ   = iLDBQ / (double)iCountLD;
                                dTongNS = dTongNS / (double)iCountLD;
                                dNSTT   = Math.Round((Double)((tongGTPX.gtNhanCongThucHien + tongGTPX.gtVatTuThucHien + tongGTPX.gtTaiSanThucHien) / iLDBQ), 2);
                            }


                            NangSuatTongThe lineNSTT = new NangSuatTongThe();
                            lineNSTT.CongDoan       = cdoan.Value;
                            lineNSTT.SoLuongLaoDong = Math.Round(iLDBQ, 0);
                            lineNSTT.ptChiPhiNc     = Math.Round(tongGTPX.ptNhanCongThucHien, 2);
                            lineNSTT.ptChiPhiVt     = Math.Round(tongGTPX.ptVatTuThucHien, 2);
                            lineNSTT.ptChiPhiTs     = Math.Round(tongGTPX.ptTaiSanThucHien, 2);
                            lineNSTT.NangSuatTT     = Math.Round(dNSTT, 2);
                            lineNSTT.NangSuatSL     = Math.Round(dTongNS, 2);
                            listNSTT.Add(lineNSTT);
                        }
                    }

                    ViewData["NSTT"] = listNSTT;

                    string strData = JsonConvert.SerializeObject(chartGiaThanhPhanXuong, Formatting.None);
                    ViewBag.DataGtpx = new HtmlString(strData);

                    ArrayList CommomArray = new ArrayList();
                    bool      iFound      = false;
                    for (int i = 0; i < chartSanLuong.Count; i++)
                    {
                        ArrayList lineCommon = new ArrayList();
                        if (i == 0) //Header
                        {
                            lineCommon.Add((object)string.Format("{0}", "Ngày"));

                            ArrayList headerSanLuong = (ArrayList)chartSanLuong[0];

                            //add header san luong
                            for (int s = 1; s < headerSanLuong.Count; s++)
                            {
                                lineCommon.Add((object)string.Format("SL-{0}", headerSanLuong[s]));
                            }

                            //add header thong ke chuyen
                            ArrayList headerStatus = (ArrayList)StatusChart[0];
                            for (int s = 1; s < headerStatus.Count; s++)
                            {
                                lineCommon.Add((object)string.Format("ST-{0}", headerStatus[s]));
                            }

                            //add header nang suat lao dong
                            ArrayList headerNS = (ArrayList)chartNangSuat[0];
                            for (int n = 1; n < headerNS.Count; n++)
                            {
                                lineCommon.Add((object)string.Format("NS-{0}", headerNS[n]));
                            }

                            //add header thong ke lao dong
                            ArrayList headerTkld = (ArrayList)TkldChart[0];
                            for (int l = 1; l < headerTkld.Count; l++)
                            {
                                lineCommon.Add((object)string.Format("LD-{0}", headerTkld[l]));
                            }
                        }
                        else //line item
                        {
                            ArrayList lineSanLuong = (ArrayList)chartSanLuong[i];

                            //add line san luong
                            for (int s = 0; s < lineSanLuong.Count; s++)
                            {
                                lineCommon.Add((lineSanLuong[s]));
                            }

                            iFound = false;
                            //add line thong ke chuyen
                            for (int y = 1; y < StatusChart.Count; y++)
                            {
                                ArrayList lineStatus = (ArrayList)StatusChart[y];
                                if (lineCommon[0].ToString() != lineStatus[0].ToString())
                                {
                                    continue;
                                }
                                iFound = true;
                                for (int s = 1; s < lineStatus.Count; s++)
                                {
                                    lineCommon.Add(lineStatus[s]);
                                }
                                break;
                            }

                            if (!iFound)
                            {
                                ArrayList lineStatus = (ArrayList)StatusChart[0];
                                for (int s = 1; s < lineStatus.Count; s++)
                                {
                                    lineCommon.Add(0);
                                }
                            }

                            iFound = false;
                            //add line nang suat
                            for (int y = 1; y < chartNangSuat.Count; y++)
                            {
                                ArrayList line = (ArrayList)chartNangSuat[y];
                                if (lineCommon[0].ToString() != line[0].ToString())
                                {
                                    continue;
                                }
                                iFound = true;
                                for (int n = 1; n < line.Count; n++)
                                {
                                    lineCommon.Add(line[n]);
                                }
                                break;
                            }

                            if (!iFound)
                            {
                                ArrayList line = (ArrayList)chartNangSuat[0];
                                for (int s = 1; s < line.Count; s++)
                                {
                                    lineCommon.Add(0);
                                }
                            }

                            //add line thong ke lao dong
                            iFound = false;
                            for (int y = 1; y < TkldChart.Count; y++)
                            {
                                ArrayList line = (ArrayList)TkldChart[y];
                                if (lineCommon[0].ToString() != line[0].ToString())
                                {
                                    continue;
                                }
                                iFound = true;
                                for (int l = 1; l < line.Count; l++)
                                {
                                    lineCommon.Add(line[l]);
                                }
                                break;
                            }
                            if (!iFound)
                            {
                                ArrayList line = (ArrayList)TkldChart[0];
                                for (int s = 1; s < line.Count; s++)
                                {
                                    lineCommon.Add(0);
                                }
                            }
                        }
                        CommomArray.Add(lineCommon);
                    }

                    strData            = JsonConvert.SerializeObject(CommomArray, Formatting.None);
                    ViewBag.DataCommon = new HtmlString(strData);

                    //*********TINH TOAN GIA THANH PHAN XUONG********************


                    if (FilterCodition.SelectedCapDo == "NGANH")
                    {
                        ViewBag.CapDo = "NGÀNH";
                    }
                    else if (FilterCodition.SelectedCapDo == "KHVUC")
                    {
                        ViewBag.CapDo = "KHU VỰC";
                    }
                    else if (FilterCodition.SelectedCapDo == "WRKCT")
                    {
                        ViewBag.CapDo = "WORK CENTER";
                    }
                    return(View("Index", FilterCodition));
                }
                catch (Exception ex)
                {
                    ViewData["SanLuongNgay"] = null;
                    ViewBag.MessagePQ        = "Chưa được cấp quyền" + ex.Message;
                    return(View("Index"));
                }
            }
        }
Beispiel #19
0
        public ActionResult RefreshCD(string GiaTriCapDoID)
        {
            string                strMandt    = "900";
            string                strSysid    = "P01";
            TKTDSXEntities        dc          = new TKTDSXEntities();
            var                   CurrentUser = Session["Username"] as BI_USER;
            List <SelectListItem> items       = new List <SelectListItem>();

            BI_PHAN_QUYEN       dataPQ = dc.BI_PHAN_QUYEN.Where(p => p.GiaTri == GiaTriCapDoID && p.Username == CurrentUser.Username).FirstOrDefault();
            IQueryable <string> listCD;
            string strTenCD = string.Empty;

            items.Add(new SelectListItem()
            {
                Text = "Tất Cả", Value = "ALL"
            });
            switch (dataPQ.CapDo)
            {
            case "NGANH":
                listCD = dc.BI_ZQLSX.Where(w => w.MANDT == strMandt && w.SYSID == strSysid &&
                                           w.NGANH == dataPQ.GiaTri).Select(s => s.CDOAN).Distinct();
                foreach (string strCD in listCD)
                {
                    strTenCD = dc.BI_ZQLSX.Where(w => w.MANDT == strMandt && w.SYSID == strSysid &&
                                                 w.NGANH == dataPQ.GiaTri).Select(s => s.TENCD).FirstOrDefault();
                    items.Add(new SelectListItem()
                    {
                        Text = strTenCD, Value = strCD
                    });
                }
                break;

            case "KHVUC":
                listCD = dc.BI_ZQLSX.Where(w => w.MANDT == strMandt && w.SYSID == strSysid &&
                                           w.KHVUC == dataPQ.GiaTri).Select(s => s.CDOAN).Distinct();
                foreach (string strCD in listCD)
                {
                    strTenCD = dc.BI_ZQLSX.Where(w => w.MANDT == strMandt && w.SYSID == strSysid &&
                                                 w.KHVUC == dataPQ.GiaTri).Select(s => s.TENCD).FirstOrDefault();
                    items.Add(new SelectListItem()
                    {
                        Text = strTenCD, Value = strCD
                    });
                }
                break;

            case "WRKCT":
                listCD = dc.BI_ZQLSX.Where(w => w.MANDT == strMandt && w.SYSID == strSysid &&
                                           w.WRKCT == dataPQ.GiaTri).Select(s => s.CDOAN).Distinct();
                foreach (string strCD in listCD)
                {
                    strTenCD = dc.BI_ZQLSX.Where(w => w.MANDT == strMandt && w.SYSID == strSysid &&
                                                 w.WRKCT == dataPQ.GiaTri).Select(s => s.TENCD).FirstOrDefault();
                    items.Add(new SelectListItem()
                    {
                        Text = strTenCD, Value = strCD
                    });
                }
                break;
            }

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
Beispiel #20
0
        public ActionResult ChangePassword(UserManager user)
        {
            var loggedUser = Session["Username"] as BI_USER;

            user.Username = loggedUser.Username;
            if (user.JobPosition == null)
            {
                user.JobPosition = loggedUser.GhiChu;
            }

            if (loggedUser == null)
            {
                RedirectToAction("Index", "Login");
            }

            if ((user.CurrentPassword == null) && (user.Password == null) &&
                (user.PasswordCofirm == null))
            {
                return(View("ChangePassword", user));
            }


            if (!ModelState.IsValid)
            {
                return(View("ChangePassword", user));
            }
            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                string strPwd     = user.CurrentPassword.Trim();
                string strEncrypt = CryptorEngine.Encrypt(strPwd, true);
                //Check exist user
                BI_USER existUser = dc.BI_USER.Where(x => x.MANDT == "900" && x.SYSID == "P01" &&
                                                     x.Username == user.Username).FirstOrDefault();
                if ((user.CurrentPassword != null) && (strEncrypt != existUser.Password))
                {
                    ModelState.AddModelError("CurrentPassword", "Current Password Incorrect");
                    return(View("ChangePassword", user));
                }
                else
                {
                    user.CurrentPassword = existUser.Password;
                }

                if ((user.Password != user.PasswordCofirm) && ((user.Password != null) || (user.PasswordCofirm != null)))
                {
                    ModelState.AddModelError("Password", "New Password do not match with confirm password");
                    return(View("ChangePassword", user));
                }

                if (user.Password == existUser.Password)
                {
                    ModelState.AddModelError("Password", "New Password must different exist password");
                    return(View("ChangePassword", user));
                }
                else
                {
                    existUser.Password = user.Password;
                    existUser.GhiChu   = user.JobPosition;

                    string newPwd = existUser.Password.Trim();

                    string strEncryptPwd = CryptorEngine.Encrypt(newPwd, true);

                    existUser.Password = strEncryptPwd;

                    dc.BI_USER.Attach(existUser);
                    var entry = dc.Entry(existUser);
                    entry.Property(e => e.Password).IsModified = true;
                    entry.Property(e => e.GhiChu).IsModified   = true;
                    dc.SaveChanges();

                    Session["Username"]           = existUser;
                    ViewBag.SuccessChangePassword = "******";
                    return(View("ChangePassword", user));
                }
            }
        }