Exemple #1
0
        public ActionResult OrganizationUnitPlanImplementation_Save(List <OrganizationUnitPlan> data)
        {
            var db     = new OrganizationUnitPlanImplementation_DAL();
            var result = new SystemMessage();

            foreach (var item in data)
            {
                item.Type       = 0;
                item.CreatedBy  = Global.CurrentUser.UserID;
                item.CreatedOn  = DateTime.Now;
                item.CreatedOn  = DateTime.Now;
                item.ModifiedBy = Global.CurrentUser.UserID;
                result          = db.OrganizationUnitPlanImplementation_Save(item);
            }
            if (result.IsSuccess == true)
            {
                result.Message = AppRes.MS_Update_success;
            }
            else
            {
                result.Message = AppRes.MS_Update_error;
            }
            return(Content(JsonConvert.SerializeObject(new
            {
                result
            })));
        }
Exemple #2
0
        public ActionResult OrganizationUnitPlanImplementation_Delete(int ID)
        {
            var db     = new OrganizationUnitPlanImplementation_DAL();
            var result = db.OrganizationUnitPlanImplementation_Delete(ID);

            if (result.IsSuccess == true)
            {
                result.Message = AppRes.MS_Update_success;
            }
            else
            {
                result.Message = AppRes.MS_Update_error;
            }
            return(Content(JsonConvert.SerializeObject(new
            {
                result
            })));
        }
Exemple #3
0
        public ActionResult TableServerSideGetData(int pageIndex, int pageSize, string filter = "")
        {
            var        db           = new OrganizationUnitPlanImplementation_DAL();
            ToTalMonth ToTalMonth   = new ToTalMonth();
            int        total        = 0;
            int        LanguageCode = Global.CurrentLanguage;
            var        result       = db.OrganizationUnitPlanImplementation_GetList(pageIndex, pageSize, filter, LanguageCode, out total, out ToTalMonth);
            var        lstTotal     = new TableColumnsTotalModel();

            lstTotal.Total1 = "15";
            lstTotal.Total2 = "25";
            lstTotal.Total3 = "35";
            lstTotal.Total4 = "45";
            lstTotal.Total5 = "55";
            return(Content(JsonConvert.SerializeObject(new
            {
                employees = result,
                totalCount = total,
                lstTotal = lstTotal,
                ToTalMonth = ToTalMonth
            })));
        }
Exemple #4
0
        public ActionResult ImportExcel()
        {
            try
            {
                if (Request != null)
                {
                    HttpPostedFileBase file = Request.Files["file-0"];
                    if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName))
                    {
                        string fileName        = file.FileName;
                        string fileContentType = file.ContentType;
                        byte[] fileBytes       = new byte[file.ContentLength];
                        var    data            = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength));
                        var    List            = new List <OrganizationUnitPlan>();

                        using (var package = new ExcelPackage(file.InputStream))
                        {
                            var currentSheet = package.Workbook.Worksheets;
                            var workSheet    = currentSheet.First();
                            var noOfCol      = workSheet.Dimension.End.Column;
                            var noOfRow      = workSheet.Dimension.End.Row;

                            for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++)
                            {
                                if (workSheet.Cells[rowIterator, 1].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 1].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 2].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 2].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 3].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 3].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 4].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 4].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 5].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 5].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 6].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 6].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 7].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 7].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 8].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 8].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 9].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 9].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 10].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 10].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 11].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 11].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 12].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 12].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 13].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 13].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 14].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 14].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 15].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 15].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 16].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 16].Value.ToString().Trim()) ||
                                    workSheet.Cells[rowIterator, 17].Value != null && !string.IsNullOrEmpty(workSheet.Cells[rowIterator, 17].Value.ToString().Trim()))
                                {
                                    var OrganizationUnitPlan = new OrganizationUnitPlan();
                                    OrganizationUnitPlan.AutoID = 0;
                                    OrganizationUnitPlan.OrganizationUnitCode = workSheet.Cells[rowIterator, 1].Value == null ? null : workSheet.Cells[rowIterator, 1].Value.ToString();
                                    OrganizationUnitPlan.OrganizationUnitName = workSheet.Cells[rowIterator, 2].Value == null ? null : workSheet.Cells[rowIterator, 2].Value.ToString();
                                    OrganizationUnitPlan.ContractType         = workSheet.Cells[rowIterator, 3].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 3].Value.ToString().Trim()) ? 0 : Convert.ToInt32(workSheet.Cells[rowIterator, 3].Value.ToString());
                                    OrganizationUnitPlan.Year        = workSheet.Cells[rowIterator, 4].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 4].Value.ToString().Trim()) ? 0 : Convert.ToInt32(workSheet.Cells[rowIterator, 4].Value.ToString());
                                    OrganizationUnitPlan.Status      = workSheet.Cells[rowIterator, 5].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 5].Value.ToString().Trim()) ? 10 : Convert.ToInt32(workSheet.Cells[rowIterator, 5].Value.ToString());
                                    OrganizationUnitPlan.M1          = workSheet.Cells[rowIterator, 6].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 6].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 6].Value.ToString());
                                    OrganizationUnitPlan.M2          = workSheet.Cells[rowIterator, 7].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 7].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 7].Value.ToString());
                                    OrganizationUnitPlan.M3          = workSheet.Cells[rowIterator, 8].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 8].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 8].Value.ToString());
                                    OrganizationUnitPlan.M4          = workSheet.Cells[rowIterator, 9].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 9].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 9].Value.ToString());
                                    OrganizationUnitPlan.M5          = workSheet.Cells[rowIterator, 10].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 10].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 10].Value.ToString());
                                    OrganizationUnitPlan.M6          = workSheet.Cells[rowIterator, 11].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 11].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 11].Value.ToString());
                                    OrganizationUnitPlan.M7          = workSheet.Cells[rowIterator, 12].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 12].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 12].Value.ToString());
                                    OrganizationUnitPlan.M8          = workSheet.Cells[rowIterator, 13].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 13].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 13].Value.ToString());
                                    OrganizationUnitPlan.M9          = workSheet.Cells[rowIterator, 14].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 14].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 14].Value.ToString());
                                    OrganizationUnitPlan.M10         = workSheet.Cells[rowIterator, 15].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 15].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 15].Value.ToString());
                                    OrganizationUnitPlan.M11         = workSheet.Cells[rowIterator, 16].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 16].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 16].Value.ToString());
                                    OrganizationUnitPlan.M12         = workSheet.Cells[rowIterator, 17].Value == null || string.IsNullOrEmpty(workSheet.Cells[rowIterator, 17].Value.ToString().Trim()) ? 0 : Convert.ToDouble(workSheet.Cells[rowIterator, 17].Value.ToString());
                                    OrganizationUnitPlan.StatusInput = 0;
                                    OrganizationUnitPlan.CreatedBy   = Global.CurrentUser.UserID;
                                    OrganizationUnitPlan.CreatedOn   = DateTime.Now;
                                    OrganizationUnitPlan.ModifiedBy  = Global.CurrentUser.UserID;
                                    OrganizationUnitPlan.ModifiedOn  = DateTime.Now;
                                    List.Add(OrganizationUnitPlan);
                                }
                            }
                        }
                        var           db        = new OrganizationUnitPlanImplementation_DAL();
                        SystemMessage SM        = new SystemMessage();
                        bool          IsSuccess = true;
                        if (List.Count() <= 0)
                        {
                            SM.IsSuccess = false;
                            SM.Message   = AppRes.ErrorNoHasData;
                            return(Content(JsonConvert.SerializeObject(new
                            {
                                SM
                            })));
                        }
                        var result = db.ImPortOrganizationUnitPlanImplementation(List, out IsSuccess);
                        if (result.Count() > 0)
                        {
                            Session["data"] = result;
                        }
                        if (IsSuccess == true)
                        {
                            SM.IsSuccess = true;
                            SM.Message   = AppRes.Success;
                        }
                        else
                        {
                            SM.IsSuccess = false;
                            SM.Message   = AppRes.ErrorImportOrganizationUnitPlanImplementation;
                        }
                        return(Content(JsonConvert.SerializeObject(new
                        {
                            result,
                            SM
                        })));
                    }
                }
            }
            catch (Exception e)
            {
                var SM = new SystemMessage();
                SM.IsSuccess = false;
                SM.Message   = AppRes.ErrorFileExcel;
                return(Content(JsonConvert.SerializeObject(new
                {
                    SM,
                })));
            }

            return(View());
        }
Exemple #5
0
        public ActionResult DownloadTemplate()
        {
            DataTable dt = new DataTable("Grid");

            dt.Columns.AddRange(new DataColumn[]
            {
                new DataColumn(AppRes.OrganazationId),
                new DataColumn(AppRes.Department),
                new DataColumn(AppRes.ContractCode),
                new DataColumn(AppRes.Year),
                new DataColumn(AppRes.StatusCode),
                new DataColumn(AppRes.L1),
                new DataColumn(AppRes.L2),
                new DataColumn(AppRes.L3),
                new DataColumn(AppRes.L4),
                new DataColumn(AppRes.L5),
                new DataColumn(AppRes.L6),
                new DataColumn(AppRes.L7),
                new DataColumn(AppRes.L8),
                new DataColumn(AppRes.L9),
                new DataColumn(AppRes.L10),
                new DataColumn(AppRes.L11),
                new DataColumn(AppRes.L12),
                new DataColumn(""),
                new DataColumn(""),
                new DataColumn(AppRes.ColumnName),
                new DataColumn(AppRes.RequestContent),
                new DataColumn(""),
                new DataColumn(""),
                new DataColumn(AppRes.ContractCode + " "),
                new DataColumn(AppRes.ContactTypeID + " " + AppRes.Contract),
                new DataColumn(""),
                new DataColumn(""),
                new DataColumn(AppRes.StatusCode + " "),
                new DataColumn(AppRes.StatusList),
            });
            dt.Columns[0].DataType  = typeof(string);
            dt.Columns[1].DataType  = typeof(string);
            dt.Columns[2].DataType  = typeof(string);
            dt.Columns[3].DataType  = typeof(string);
            dt.Columns[4].DataType  = typeof(string);
            dt.Columns[5].DataType  = typeof(string);
            dt.Columns[6].DataType  = typeof(string);
            dt.Columns[7].DataType  = typeof(string);
            dt.Columns[8].DataType  = typeof(string);
            dt.Columns[9].DataType  = typeof(string);
            dt.Columns[10].DataType = typeof(string);
            dt.Columns[11].DataType = typeof(string);
            dt.Columns[12].DataType = typeof(string);
            dt.Columns[13].DataType = typeof(string);
            dt.Columns[14].DataType = typeof(string);
            dt.Columns[15].DataType = typeof(string);
            dt.Columns[16].DataType = typeof(string);
            dt.Columns[17].DataType = typeof(string);
            dt.Columns[18].DataType = typeof(string);
            dt.Columns[19].DataType = typeof(string);
            dt.Columns[20].DataType = typeof(string);
            dt.Columns[21].DataType = typeof(string);
            dt.Columns[22].DataType = typeof(string);
            dt.Columns[23].DataType = typeof(string);
            dt.Columns[24].DataType = typeof(string);
            dt.Columns[25].DataType = typeof(string);
            dt.Columns[26].DataType = typeof(string);
            dt.Columns[27].DataType = typeof(string);
            dt.Columns[28].DataType = typeof(string);
            var        db              = new OrganizationUnitPlanImplementation_DAL();
            ToTalMonth ToTalMonth      = new ToTalMonth();
            var        commonDAL       = new CommonDal();
            var        listContratType = commonDAL.GetsWhereParentIDnotTree(1949, Global.CurrentLanguage);
            var        listStatus      = commonDAL.GetsWhereParentIDnotTree(88, Global.CurrentLanguage);

            List <string> ListColumn = new List <string>()
            {
                AppRes.OrganazationId, AppRes.Department, AppRes.ContractCode, AppRes.Year, AppRes.StatusName, AppRes.L1, AppRes.L2, AppRes.L3, AppRes.L4, AppRes.L5, AppRes.L6, AppRes.L7, AppRes.L8, AppRes.L9
                , AppRes.L10, AppRes.L11, AppRes.L12
            };

            List <string> ListRequest = new List <string>()
            {
                AppRes.RequestStaffCode, AppRes.RequestStaffName, AppRes.RequestContractCode, AppRes.RequestYear, AppRes.RequestStaffCode, AppRes.RequestMonthInYear, AppRes.RequestMonthInYear
                , AppRes.RequestMonthInYear, AppRes.RequestMonthInYear, AppRes.RequestMonthInYear, AppRes.RequestMonthInYear, AppRes.RequestMonthInYear, AppRes.RequestMonthInYear
                , AppRes.RequestMonthInYear, AppRes.RequestMonthInYear, AppRes.RequestMonthInYear, AppRes.RequestMonthInYear
            };

            int total        = 0;
            int LanguageCode = Global.CurrentUser.CurrentLanguageID;
            var rowsNumber   = 0;

            if (ListColumn.Count > listContratType.Count)
            {
                rowsNumber = ListColumn.Count;
            }
            else
            {
                rowsNumber = listContratType.Count;
            }
            for (int i = 0; i < rowsNumber; i++)
            {
                dt.Rows.Add(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, ListColumn.Count() > i ? ListColumn[i] : " ", ListRequest.Count() > i ? ListRequest[i] : " ", " ", " ", listContratType.Count() > i ? listContratType[i].GlobalListID.ToString() : " ", listContratType.Count > i ? (Global.CurrentLanguage == 5 ? listContratType[i].Name : listContratType[i].NameEN) : " ", " ", " ", listStatus.Count() > i ? listStatus[i].Value.ToString() : " ", listStatus.Count() > i?(Global.CurrentLanguage == 5 ? listStatus[i].Name : listStatus[i].NameEN) : " ");
            }
            var wb = new XLWorkbook();

            wb.Worksheets.Add(dt);
            wb.Worksheet("Grid").Column(18).Style.Fill.BackgroundColor = XLColor.White;
            wb.Worksheet("Grid").Column(19).Style.Fill.BackgroundColor = XLColor.White;
            wb.Worksheet("Grid").Column(22).Style.Fill.BackgroundColor = XLColor.White;
            wb.Worksheet("Grid").Column(23).Style.Fill.BackgroundColor = XLColor.White;
            wb.Worksheet("Grid").Column(26).Style.Fill.BackgroundColor = XLColor.White;
            wb.Worksheet("Grid").Column(27).Style.Fill.BackgroundColor = XLColor.White;
            byte[] data = null;
            using (var stream = new MemoryStream())
            {
                wb.SaveAs(stream);
                data = stream.ToArray();
            }
            return(File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "TemplateOrganizationUnitPlanImplementation.xlsx"));
        }
Exemple #6
0
        public ActionResult OrganizationUnitPlanImplementationExportExcel(string filter = "")
        {
            DataTable dt = new DataTable("Grid");

            if (filter.Contains("!!") == true)
            {
                filter = filter.Replace("!!", "%");
            }
            dt.Columns.AddRange(new DataColumn[]
            {
                new DataColumn(AppRes.OrganizationUnit),
                new DataColumn(AppRes.Currency),
                new DataColumn(AppRes.Contract),
                new DataColumn(AppRes.Year),
                new DataColumn(AppRes.StatusName),
                new DataColumn(AppRes.L1),
                new DataColumn(AppRes.L2),
                new DataColumn(AppRes.L3),
                new DataColumn(AppRes.L4),
                new DataColumn(AppRes.L5),
                new DataColumn(AppRes.L6),
                new DataColumn(AppRes.L7),
                new DataColumn(AppRes.L8),
                new DataColumn(AppRes.L9),
                new DataColumn(AppRes.L10),
                new DataColumn(AppRes.L11),
                new DataColumn(AppRes.L12),
                new DataColumn(AppRes.R_Total),
                new DataColumn(AppRes.StatusInput),
            });
            dt.Columns[0].DataType  = typeof(string);
            dt.Columns[1].DataType  = typeof(string);
            dt.Columns[2].DataType  = typeof(string);
            dt.Columns[3].DataType  = typeof(string);
            dt.Columns[4].DataType  = typeof(string);
            dt.Columns[5].DataType  = typeof(string);
            dt.Columns[6].DataType  = typeof(double);
            dt.Columns[7].DataType  = typeof(double);
            dt.Columns[8].DataType  = typeof(double);
            dt.Columns[9].DataType  = typeof(double);
            dt.Columns[10].DataType = typeof(double);
            dt.Columns[11].DataType = typeof(double);
            dt.Columns[12].DataType = typeof(double);
            dt.Columns[13].DataType = typeof(double);
            dt.Columns[14].DataType = typeof(double);
            dt.Columns[15].DataType = typeof(double);
            dt.Columns[16].DataType = typeof(double);
            dt.Columns[17].DataType = typeof(double);
            dt.Columns[18].DataType = typeof(string);

            var        db         = new OrganizationUnitPlanImplementation_DAL();
            ToTalMonth ToTalMonth = new ToTalMonth();

            int total        = 0;
            int LanguageCode = Global.CurrentUser.CurrentLanguageID;
            var lstData      = db.OrganizationUnitPlanImplementation_GetList(1, 100000, filter, LanguageCode, out total, out ToTalMonth);

            if (lstData != null && lstData.Count() > 0)
            {
                foreach (var item in lstData)
                {
                    dt.Rows.Add(item.OrganizationUnitName, item.CurrencyName, item.ContractTypeName, item.Year, item.StatusName, item.M1, item.M2, item.M3, item.M4, item.M5, item.M6, item.M7, item.M8, item.M9, item.M10, item.M11, item.M12, item.SumValue, item.StatusInputName);
                }
            }


            var wb = new XLWorkbook();

            wb.Worksheets.Add(dt);
            byte[] data = null;
            using (var stream = new MemoryStream())
            {
                wb.SaveAs(stream);
                data = stream.ToArray();
            }
            return(File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", " OrganizationUnitPlanImplementation.xlsx"));
        }