Пример #1
0
        public List <DC_LG_Transporter_Location> 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", param);
            var       lst = new List <DC_LG_Transporter_Location>();

            foreach (DataRow row in dt.Rows)
            {
                var item = new DC_LG_Transporter_Location();
                item.TransporterLocationID   = !row.IsNull("TransporterLocationID") ? int.Parse(row["TransporterLocationID"].ToString()) : 0;
                item.TransporterLocationName = !row.IsNull("TransporterLocationName") ? row["TransporterLocationName"].ToString() : "";
                item.TransporterID           = !row.IsNull("TransporterID") ? int.Parse(row["TransporterID"].ToString()) : 0;
                item.IsAllMerchant           = !row.IsNull("IsAllMerchant") ? Convert.ToBoolean(row["IsAllMerchant"]) : false;;
                item.Status          = !row.IsNull("Status") ? Convert.ToBoolean(row["Status"]) : false;
                item.Note            = !row.IsNull("Note") ? row["Note"].ToString() : "";
                item.TransporterName = !row.IsNull("TransporterName") ? row["TransporterName"].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);
        }
Пример #2
0
 public ActionResult Read_TransporterLocation([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().GetPage(request.Page,request.PageSize, whereCondition);
     return Json(data);
 }
Пример #3
0
 public FileResult Export_TransporterLocation([DataSourceRequest]DataSourceRequest request)
 {
     ExcelPackage pck = new ExcelPackage(new FileInfo(Server.MapPath("~/ExportTemplate/DiaBanVanChuyen.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().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.IsAllMerchant? 1 : 0;
             ws.Cells["D" + rowNum].Value = item.TransporterID;
             ws.Cells["E" + rowNum].Value = item.TransporterName;
             ws.Cells["F" + rowNum].Value = item.Note;
             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
                 "DiaBanVanChuyen" + 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> 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", param);
            var lst = new List<DC_LG_Transporter_Location>();
            foreach (DataRow row in dt.Rows)
            {
                var item = new DC_LG_Transporter_Location();
                item.TransporterLocationID = !row.IsNull("TransporterLocationID") ? int.Parse(row["TransporterLocationID"].ToString()) : 0;
                item.TransporterLocationName = !row.IsNull("TransporterLocationName") ? row["TransporterLocationName"].ToString() : "";
                item.TransporterID = !row.IsNull("TransporterID") ? int.Parse(row["TransporterID"].ToString()) : 0;
                item.IsAllMerchant = !row.IsNull("IsAllMerchant") ? Convert.ToBoolean(row["IsAllMerchant"]) : false; ;
                item.Status = !row.IsNull("Status") ? Convert.ToBoolean(row["Status"]) : false;
                item.Note = !row.IsNull("Note") ? row["Note"].ToString() : "";
                item.TransporterName = !row.IsNull("TransporterName") ? row["TransporterName"].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;
        }