Esempio n. 1
0
        public List <DC_LG_Transporter_Location_Territory> Getlist(string whereCondition)
        {
            List <SqlParameter> param = new List <SqlParameter>();

            param.Add(new SqlParameter("@Page", 1));
            param.Add(new SqlParameter("@PageSize", 999999));
            param.Add(new SqlParameter("@WhereCondition", whereCondition));
            DataTable dt  = new SqlHelper().ExecuteQuery("p_get_DC_TransporterLocation_Territoty", param);
            var       lst = new List <DC_LG_Transporter_Location_Territory>();

            foreach (DataRow row in dt.Rows)
            {
                var item = new DC_LG_Transporter_Location_Territory();
                item.TransporterLocationID   = !row.IsNull("TransporterLocationID") ? int.Parse(row["TransporterLocationID"].ToString()) : 0;
                item.TransporterLocationName = !row.IsNull("TransporterLocationName") ? row["TransporterLocationName"].ToString() : "";
                item.ProvinceID   = !row.IsNull("ProvinceID") ? row["ProvinceID"].ToString() : "";
                item.DistrictID   = !row.IsNull("DistrictID") ? row["DistrictID"].ToString() : "";
                item.ProvinceName = !row.IsNull("ProvinceName") ? row["ProvinceName"].ToString() : "";
                item.DistrictName = !row.IsNull("DistrictName") ? row["DistrictName"].ToString() : "";
                item.Status       = !row.IsNull("Status") ? Convert.ToBoolean(row["Status"]) : false;
                item.Note         = !row.IsNull("Note") ? row["Note"].ToString() : "";

                //  item.CreatedBy = !row.IsNull("CreatedBy") ? row["CreatedBy"].ToString() : "";
                //  item.UpdatedBy = !row.IsNull("UpdatedBy") ? row["UpdatedBy"].ToString() : "";
                //  item.CreatedAt = !row.IsNull("CreatedAt") ? DateTime.Parse(row["CreatedAt"].ToString()) : DateTime.Parse("01/01/1900");
                //  item.UpdatedAt = !row.IsNull("UpdatedAt") ? DateTime.Parse(row["UpdatedAt"].ToString()) : DateTime.Parse("01/01/1900");

                lst.Add(item);
            }
            return(lst);
        }
Esempio n. 2
0
 public ActionResult Read_TransporterLocation_Territory([DataSourceRequest]DataSourceRequest request)
 {
     var dbConn = new OrmliteConnection().openConn();
     string whereCondition = "";
     if (request.Filters.Count > 0)
     {
         whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]);
     }
     var data = new DC_LG_Transporter_Location_Territory().GetPage(request.Page, request.PageSize, whereCondition);
     return Json(data);
 }
Esempio n. 3
0
        public FileResult Export_TransporterLocation_Territory([DataSourceRequest]DataSourceRequest request)
        {
            ExcelPackage pck = new ExcelPackage(new FileInfo(Server.MapPath("~/ExportTemplate/DiaBanVanChuyenTheoVung.xlsx")));
            ExcelWorksheet ws = pck.Workbook.Worksheets["Data"];
            if (userAsset["Export"])
            {
                string whereCondition = "";
                if (request.Filters.Count > 0)
                {
                    whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]);
                }
                IDbConnection db = new OrmliteConnection().openConn();
                var lstResult = new DC_LG_Transporter_Location_Territory().Getlist(whereCondition);
                int rowNum = 2;
                foreach (var item in lstResult)
                {
                    ws.Cells["A" + rowNum].Value = item.TransporterLocationID;
                    ws.Cells["B" + rowNum].Value = item.TransporterLocationName;
                    ws.Cells["C" + rowNum].Value = item.ProvinceID;
                    ws.Cells["D" + rowNum].Value = item.ProvinceName;
                    ws.Cells["E" + rowNum].Value = item.DistrictID;
                    ws.Cells["F" + rowNum].Value = item.DistrictName;
                    ws.Cells["G" + rowNum].Value = item.Note;
                    ws.Cells["H" + rowNum].Value = item.Status ? "Đang hoạt động" : "Ngưng hoạt động";

                    //ws.Cells["F" + rowNum].Value = item.PickingProvinceID + "-" + item.PickingProvinceName;
                    //ws.Cells["G" + rowNum].Value = item.CreatedBy;
                    //ws.Cells["H" + rowNum].Value = Convert.ToDateTime(item.CreatedAt).ToString("dd/MM/yyyy");
                    //ws.Cells["I" + rowNum].Value = item.Status ? "Đang hoạt động" : "Ngưng hoạt động";
                    rowNum++;
                }
                db.Close();
            }
            else
            {
                ws.Cells["A2:E2"].Merge = true;
                ws.Cells["A2"].Value = "You don't have permission to export data.";
            }
            MemoryStream output = new MemoryStream();
            pck.SaveAs(output);
            return File(output.ToArray(), //The binary data of the XLS file
                        "application/vnd.ms-excel", //MIME type of Excel files
                        "DiaBanVanChuyenTheoVung" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx");     //Suggested file name in the "Save as" dialog which will be displayed to the end user
        }
        public List<DC_LG_Transporter_Location_Territory> Getlist(string whereCondition)
        {
            List<SqlParameter> param = new List<SqlParameter>();
            param.Add(new SqlParameter("@Page", 1));
            param.Add(new SqlParameter("@PageSize", 999999));
            param.Add(new SqlParameter("@WhereCondition", whereCondition));
            DataTable dt = new SqlHelper().ExecuteQuery("p_get_DC_TransporterLocation_Territoty", param);
            var lst = new List<DC_LG_Transporter_Location_Territory>();
            foreach (DataRow row in dt.Rows)
            {
                var item = new DC_LG_Transporter_Location_Territory();
                item.TransporterLocationID = !row.IsNull("TransporterLocationID") ? int.Parse(row["TransporterLocationID"].ToString()) : 0;
                item.TransporterLocationName = !row.IsNull("TransporterLocationName") ? row["TransporterLocationName"].ToString() : "";
                item.ProvinceID = !row.IsNull("ProvinceID") ? row["ProvinceID"].ToString() : "";
                item.DistrictID = !row.IsNull("DistrictID") ? row["DistrictID"].ToString() : "";
                item.ProvinceName = !row.IsNull("ProvinceName") ? row["ProvinceName"].ToString() : "";
                item.DistrictName = !row.IsNull("DistrictName") ? row["DistrictName"].ToString() : "";
                item.Status = !row.IsNull("Status") ? Convert.ToBoolean(row["Status"]) : false;
                item.Note = !row.IsNull("Note") ? row["Note"].ToString() : "";

                //  item.CreatedBy = !row.IsNull("CreatedBy") ? row["CreatedBy"].ToString() : "";
                //  item.UpdatedBy = !row.IsNull("UpdatedBy") ? row["UpdatedBy"].ToString() : "";
                //  item.CreatedAt = !row.IsNull("CreatedAt") ? DateTime.Parse(row["CreatedAt"].ToString()) : DateTime.Parse("01/01/1900");
                //  item.UpdatedAt = !row.IsNull("UpdatedAt") ? DateTime.Parse(row["UpdatedAt"].ToString()) : DateTime.Parse("01/01/1900");

                lst.Add(item);
            }
            return lst;
        }