Ejemplo n.º 1
0
        protected void btnDownloadTemplate_Click(object sender, EventArgs e)
        {
            //根据输入的Storename, 查询StoreType=Import的数据到Excel下载

            DataSet dsData = MainService.StoreBLLService.QueryByCondition<StoreEntity>(
                 BPSC.Common.Utils.QueryCondition.Create()
                 .Like(StoreTable.C_STORE_NAME, txtStoreName.Text.Trim())
                  //.Equals(StoreTable.C_STORE_TYPE, BPSC.Common.StoreType.Import.ToString())
                  .NotEquals(StoreTable.C_IS_DELETED, "Y"));

            DataTable dtData = new DataTable();
            if (dsData != null && dsData.Tables.Count > 0 && dsData.Tables[0].Rows.Count > 0)
            {
                dtData = dsData.Tables[0];
                for (int i = dtData.Columns.Count - 1; i > 23; i--)
                {
                    dtData.Columns.RemoveAt(i);
                }
                dtData.Columns.RemoveAt(0);
            }

            BPSC.Common.ExcelTemplate excelTemplalte = new BPSC.Common.ExcelTemplate("Store_Import_Template.xls");
            //excelTemplalte.
            excelTemplalte.Export(dtData, "Store_Import_Template" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
        }
Ejemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.fudCriminal.HasFile)
            {
                base.AlertMessage("Please select file.");
                this.fudCriminal.Focus();
                return;
            }

            BPSC.Common.ExcelTemplate excelTemplate = new BPSC.Common.ExcelTemplate("Criminal_Template.xls");
            bool isValid = true;
            DataTable dt = excelTemplate.GetDataFromExcel(fudCriminal, out isValid);
            if (!isValid)
            {
                AlertMessage("The format of criminal file is error. Please check it, try again later.");
                return;
            }

            #region 验证所有数据的格式正确性
            for (int j = 0; j < dt.Rows.Count; j++)
            {                
                if (dt.Rows[j][1].ToString().Trim() == "")
                {
                    AlertMessage("Data empty, 'Action NO.'.");
                    this.fudCriminal.Focus();
                    return;
                }
                if (!CheckActionNOIsExist(dt.Rows[j][1].ToString().Trim()))
                {
                    AlertMessage("'Action NO.' doesn't exist ");
                    this.fudCriminal.Focus();
                    return;
                }

                try
                {
                    Convert.ToDateTime(dt.Rows[j][8]);
                }
                catch (Exception ex)
                {
                    AlertMessage("Data format is error, 'Raid Date'.");
                    this.fudCriminal.Focus();
                    return;
                }

                #region 模板更新
                //模板更新,取消Length Of Sentence probation、Length Of Sentence imprisonment、Punished with Criminal Fine、Confiscate illegal gains,新增Result
                //try
                //{
                //    Convert.ToInt32(dt.Rows[j][17]);
                //}
                //catch
                //{
                //    AlertMessage("Data format is error, 'Length Of Sentence probation'.");
                //    this.fudCriminal.Focus();
                //    return;
                //}

                //try
                //{
                //    Convert.ToInt32(dt.Rows[j][18]);
                //}
                //catch
                //{
                //    AlertMessage("Data format is error, 'Length Of Sentence imprisonment'.");
                //    this.fudCriminal.Focus();
                //    return;
                //}
                //try
                //{
                //    Convert.ToDouble(dt.Rows[j][19]);
                //}
                //catch
                //{
                //    AlertMessage("Data format is error, 'Punished with Criminal Fine'.");
                //    this.fudCriminal.Focus();
                //    return;
                //}
                //try
                //{
                //    Convert.ToDouble(dt.Rows[j][20]);
                //}
                //catch
                //{
                //    AlertMessage("Data format is error, 'Confiscate illegal gains'.");
                //    this.fudCriminal.Focus();
                //    return;
                //}
                #endregion

                try
                {
                    Convert.ToDateTime(dt.Rows[j][18]);
                }
                catch (Exception ex)
                {
                    AlertMessage("Data format is error, 'Conviction Date'.");
                    this.fudCriminal.Focus();
                    return;
                }

                try
                {
                    Convert.ToDateTime(dt.Rows[j][22]);
                }
                catch (Exception ex)
                {
                    AlertMessage("Data format is error, 'Criminal Date'.");
                    this.fudCriminal.Focus();
                    return;
                }

                try
                {
                    Convert.ToDateTime(dt.Rows[j][23]);
                }
                catch (Exception ex)
                {
                    AlertMessage("Data format is error, 'Report Received Date'.");
                    this.fudCriminal.Focus();
                    return;
                }
            }
            #endregion

            CriminalDetailEntity criminalDetailEntity = null;
            List<CriminalDetailEntity> lstCriminalDetailEntity = new List<CriminalDetailEntity>();
            #region Insert Data
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                criminalDetailEntity = new CriminalDetailEntity();
                criminalDetailEntity.CriminalDetailId = Guid.NewGuid().ToString();
                criminalDetailEntity.ActionNo = dt.Rows[i][1].ToString();
                criminalDetailEntity.Sequence = dt.Rows[i][0].ToString();
                criminalDetailEntity.Province = dt.Rows[i][2].ToString();
                criminalDetailEntity.City = dt.Rows[i][3].ToString();
                criminalDetailEntity.WholesalerManufacturer = dt.Rows[i][4].ToString();
                criminalDetailEntity.PngBrand = dt.Rows[i][5].ToString();
                criminalDetailEntity.OtherBrand = dt.Rows[i][6].ToString();
                criminalDetailEntity.Defendant = dt.Rows[i][7].ToString();
                criminalDetailEntity.RaidDate = Convert.ToDateTime(dt.Rows[i][8]);
                criminalDetailEntity.Seizure = dt.Rows[i][9].ToString();
                criminalDetailEntity.EstimatedValueUsd = dt.Rows[i][10].ToString();
                criminalDetailEntity.PsbUnit = dt.Rows[i][11].ToString();
                criminalDetailEntity.PpUnit = dt.Rows[i][12].ToString();
                criminalDetailEntity.CourtUnit = dt.Rows[i][13].ToString();
                criminalDetailEntity.BasisOfConviction = dt.Rows[i][14].ToString();
                criminalDetailEntity.LawFirm = dt.Rows[i][15].ToString();
                criminalDetailEntity.FirmNameAndDate = dt.Rows[i][16].ToString();

                #region 模板更新, 一下index重排
                //模板更新,取消Length Of Sentence probation、Length Of Sentence imprisonment、Punished with Criminal Fine、Confiscate illegal gains,新增Result
                //criminalDetailEntity.Lengthofsentenceprobation = Convert.ToInt32(dt.Rows[i][17]);
                //criminalDetailEntity.Lengthofsentenceofimprisonment = Convert.ToInt32(dt.Rows[i][18]);
                //criminalDetailEntity.Punishedwidthcriminalfine = Convert.ToDecimal(dt.Rows[i][19]);
                //criminalDetailEntity.ConfiscateIllegalGains = Convert.ToDecimal(dt.Rows[i][20]);
                #endregion
                criminalDetailEntity.Result = dt.Rows[i][17].ToString();
                criminalDetailEntity.ConvictionDate = Convert.ToDateTime(dt.Rows[i][18]);
                criminalDetailEntity.AllAssistingUnits = dt.Rows[i][19].ToString();
                criminalDetailEntity.KeyPoints = dt.Rows[i][20].ToString();
                criminalDetailEntity.Document = dt.Rows[i][21].ToString();

                criminalDetailEntity.CreateDate = DateTime.Now;
                criminalDetailEntity.CreateUser = base.CurrentUser.SecUserEntity.UserId;

                //新增Criminal Date列
                criminalDetailEntity.CriminalDate = Convert.ToDateTime(dt.Rows[i][22]);

                //新增Report Received Date列
                criminalDetailEntity.Reportreceivedday = Convert.ToDateTime(dt.Rows[i][23]);

                lstCriminalDetailEntity.Add(criminalDetailEntity);
            }
            #endregion

            int total_success_import = 0;
            int total_valid_product = lstCriminalDetailEntity.Count;
            foreach (CriminalDetailEntity entity in lstCriminalDetailEntity)
            {

                if (MainService.CriminalDetailBLLService.InsertCriminalRaid(entity, ddlAgency.SelectedItem.Text, ddlAgency.SelectedValue.Trim(), true,ddlUser.SelectedItem.Text,ddlUser.SelectedValue.Trim()))
                    total_success_import += 1;
            }

            if (total_success_import > 0)
            {
                base.AlertMessage(total_success_import.ToString() + " criminals is valid, and import successfully!");
            }
            else
            {
                base.AlertMessage("All criminals is invalid. Please check, try it later.");
            }

        }
Ejemplo n.º 3
0
 protected void btnDownload_Click(object sender, EventArgs e)
 {
     BPSC.Common.ExcelTemplate excelTemplalte = new BPSC.Common.ExcelTemplate("Criminal_Template.xls");
     excelTemplalte.Export("Criminal_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
 }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //更新或新增数据
            int total_valid_product = 0;
            int total_success_import = 0;

            if (upLoadFile.FileName.Length == 0)
            {
                base.AlertMessage("Please choose store file.");
                return;
            }

            BPSC.Common.ExcelTemplate excelTemplate = new BPSC.Common.ExcelTemplate("Store_Import_Template.xls");
            bool isValid = true;
            DataTable dt_product = excelTemplate.GetDataFromExcel(upLoadFile, out isValid);
            if (!isValid)
            {
                base.AlertMessage("The format of store file is error. Please check it, try again later.");
                return;
            }

            //DMS_ID,DMS_STORE_ID,STORE_NAME 不能为空
            #region 验证所有数据的格式正确性
            for (int j = 0; j < dt_product.Rows.Count; j++)
            {
                //if (dt_product.Rows[j][6].ToString().Trim() == "" || dt_product.Rows[j][8].ToString().Trim() == "" || dt_product.Rows[j][9].ToString().Trim() == "")
                //{
                //    base.AlertMessage("'DMS_ID'、'DMS_STORE_ID' and 'STORE_NAME' can not be empty.");
                //    this.upLoadFile.Focus();
                //    return;
                //}

                if (dt_product.Rows[j][7].ToString().Trim() == "" && dt_product.Rows[j][8].ToString().Trim() == "")
                {
                    base.AlertMessage("If 'Store SEQ' is null, 'BP Store SEQ' must be enter.");
                    this.upLoadFile.Focus();
                    return;
                }

                if (dt_product.Rows[j][10].ToString().Trim() == "")
                {
                    base.AlertMessage("Store Name can not be empty.");
                    this.upLoadFile.Focus();
                    return;
                }
            }
            #endregion

            total_valid_product = dt_product.Rows.Count;
            if (cbxOverwriteAll.Checked) //全量更新
            {
                //1.将所有StoreType=Import 且 IS_DELETED!=N 的记录都删除(将IS_DELETED=Y)
                //2 将Excel中所有记录新增的table
                total_success_import = MainService.StoreBLLService.StoreOverwriteAll(dt_product, base.CurrentUser.SecUserEntity.UserId);
            }
            else
            {
                total_success_import = MainService.StoreBLLService.StoreUpdateOrInsert(dt_product, base.CurrentUser.SecUserEntity.UserId);
            }


            if (total_success_import > 0)
            {
                base.AlertMessage(total_success_import.ToString() + " stores are valid, and import successfully!");
            }
            else
            {
                base.AlertMessage("All stores are invalid. Please check, try it later.");
            }
        }
Ejemplo n.º 5
0
        protected void lnkEmptyTemplate_Click(object sender, EventArgs e)
        {
            //根据输入的Storename, 查询StoreType=Import的数据到Excel下载

            DataSet dsData = MainService.StoreBLLService.QueryByCondition<StoreEntity>(
                 BPSC.Common.Utils.QueryCondition.Create()
                 .Equals("1", "0"));

            DataTable dtData = new DataTable();
            if (dsData != null && dsData.Tables.Count > 0)
            {
                dtData = dsData.Tables[0];
                for (int i = dtData.Columns.Count - 1; i > 23; i--)
                {
                    dtData.Columns.RemoveAt(i);
                }
                dtData.Columns.RemoveAt(0);
            }

            BPSC.Common.ExcelTemplate excelTemplalte = new BPSC.Common.ExcelTemplate("Store_Import_Template.xls");
            //excelTemplalte.
            excelTemplalte.Export(dtData, "Store_Import_Template" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");

        }
Ejemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.fudCriminal.HasFile)
            {
                base.AlertMessage("Please select file.");
                this.fudCriminal.Focus();
                return;
            }

            #region Sub-Distributor
            if (OtherRaidType == "SubRaid")
            {
            }

            BPSC.Common.ExcelTemplate excelTemplate = new BPSC.Common.ExcelTemplate("Market_Sweep_SubDistributor_Template.xls");
            bool isValid = true;
            DataTable dt = excelTemplate.GetDataFromExcel(fudCriminal, out isValid);
            if (!isValid)
            {
                AlertMessage("The format of raid file is error. Please check it, try again later.");
                return;
            }

            StoreEntity storeEntity = null;
            AreaEntity areaEntity = null;
            DataSet dsTemp = null;
            List<NormalRaidEntity> listNormalRaidEntity = new List<NormalRaidEntity>();
            NormalRaidEntity normalRaidEntity = null;
            int colIndex = 0;
            string actionNo, actionDate, storeSeq, I_Or_Raid;
            for (int j = 0; j < dt.Rows.Count; j++)
            {
                normalRaidEntity = new NormalRaidEntity();
                colIndex = 0;
                I_Or_Raid = dt.Rows[j][0].ToString().Trim();
                if(I_Or_Raid != "Investigation" && I_Or_Raid != "Raid")
                {
                    AlertMessage(string.Format("IOrRaid value is not 'Investigation' or 'Raid'! {0} is wrong!",I_Or_Raid));
                    this.fudCriminal.Focus();
                    return;
                }
                actionNo = dt.Rows[j][4].ToString().Trim();
                if (CheckActionNOIsExist(actionNo))
                {
                    AlertMessage("Investigation  NO is exist, please try another again! ");
                    this.fudCriminal.Focus();
                    return;
                }

                try
                {
                    actionDate = dt.Rows[j][5].ToString().Trim();
                    normalRaidEntity.ActionDate = Convert.ToDateTime(actionDate);
                }
                catch (Exception ex)
                {
                    AlertMessage("ActionDate format error.");
                    this.fudCriminal.Focus();
                    return;
                }

                //Subject SEQ
                storeSeq = dt.Rows[j][8].ToString().Trim();
                storeEntity = MainService.StoreBLLService.GetStoreEntityByIdStoreSeq(storeSeq);
                if (storeEntity == null)
                {
                    AlertMessage("Store not exist");
                    this.fudCriminal.Focus();
                    return;
                }
                else
                {
                    normalRaidEntity.StoreName = storeEntity.StoreName;
                    normalRaidEntity.StoreId = storeEntity.StoreId;

                    normalRaidEntity.Province = storeEntity.Province;
                    normalRaidEntity.City = storeEntity.City;
                    normalRaidEntity.SubCity = storeEntity.Village;

                    areaEntity = null;
                    areaEntity = MainService.AreaBLLService.GetAreaEntityByLevelCHName(1, storeEntity.Province.Trim());
                    if (areaEntity != null && areaEntity.AreaId != null)
                    {
                        normalRaidEntity.ProvinceId = areaEntity.AreaId;
                    }
                    else
                    {
                        normalRaidEntity.ProvinceId = -1;
                    }

                    areaEntity = null;
                    areaEntity = MainService.AreaBLLService.GetAreaEntityByLevelCHNamePID(2, storeEntity.City.Trim(), normalRaidEntity.ProvinceId);
                    if (areaEntity != null && areaEntity.AreaId != null)
                    {
                        normalRaidEntity.CityId = areaEntity.AreaId;
                    }
                    else
                    {
                        normalRaidEntity.CityId = -1;
                    }

                    areaEntity = null;
                    areaEntity = MainService.AreaBLLService.GetAreaEntityByLevelCHNamePID(3, storeEntity.Village.Trim(), normalRaidEntity.CityId);
                    if (areaEntity != null && areaEntity.AreaId != null)
                    {
                        normalRaidEntity.SubCityId = areaEntity.AreaId;
                    }
                    else
                    {
                        normalRaidEntity.SubCityId = -1;
                    }
                }


                normalRaidEntity.Type = OtherRaidType;

                //normalRaidEntity.IOrRaid = "Investigation"; // 1是Investigation
                normalRaidEntity.IOrRaid = dt.Rows[j][colIndex++].ToString().Trim();
                normalRaidEntity.SourceType = dt.Rows[j][colIndex++].ToString().Trim();
                normalRaidEntity.SourceId = dt.Rows[j][colIndex++].ToString().Trim();
                normalRaidEntity.Project = dt.Rows[j][colIndex++].ToString().Trim();
                normalRaidEntity.No = dt.Rows[j][colIndex++].ToString().Trim();
                colIndex++;
                //normalRaidEntity.ActionDate = Convert.ToDateTime(dt.Rows[j][4].ToString().Trim()); //前面已赋值
                normalRaidEntity.Region = dt.Rows[j][colIndex++].ToString().Trim();  //"GC";
                normalRaidEntity.Country = dt.Rows[j][colIndex++].ToString().Trim(); //"China";
                normalRaidEntity.SubjectSeq = dt.Rows[j][colIndex++].ToString().Trim();


                normalRaidEntity.Enforcementunit = dt.Rows[j][colIndex++].ToString().Trim();
                dsTemp = null;
                dsTemp = MainService.NormalRaidBLLService.QueryByCondition<SysParameterEntity>(
                                              BPSC.Common.Utils.QueryCondition.Create()
                                              .Equals(SysParameterTable.C_PARAMETER_TYPE, "EnforcementUnit")
                                              .Equals(SysParameterTable.C_PARAMETER_NAME, normalRaidEntity.Enforcementunit));
                if (dsTemp != null && dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
                {
                    normalRaidEntity.EnforcementunitId = dsTemp.Tables[0].Rows[0][SysParameterTable.C_PARAMETER_VALUE].ToString().Trim();
                }

                normalRaidEntity.ExecutionArea = dt.Rows[j][colIndex++].ToString().Trim();
                normalRaidEntity.ExecutionUnit = dt.Rows[j][colIndex++].ToString().Trim();

                normalRaidEntity.SubjectType = dt.Rows[j][colIndex++].ToString().Trim();
                dsTemp = null;
                dsTemp = MainService.NormalRaidBLLService.QueryByCondition<SysParameterEntity>(
                                              BPSC.Common.Utils.QueryCondition.Create()
                                              .Equals(SysParameterTable.C_PARAMETER_TYPE, "SubjectType")
                                              .Equals(SysParameterTable.C_PARAMETER_NAME, normalRaidEntity.SubjectType));
                if (dsTemp != null && dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
                {
                    normalRaidEntity.SubjectTypeId = dsTemp.Tables[0].Rows[0][SysParameterTable.C_PARAMETER_VALUE].ToString().Trim();
                }

                normalRaidEntity.SubSubjectType = dt.Rows[j][colIndex++].ToString().Trim();
                dsTemp = null;
                dsTemp = MainService.NormalRaidBLLService.QueryByCondition<SysParameterEntity>(
                                              BPSC.Common.Utils.QueryCondition.Create()
                                              .Equals(SysParameterTable.C_PARAMETER_TYPE, normalRaidEntity.SubjectType)
                                              .Equals(SysParameterTable.C_PARAMETER_NAME, normalRaidEntity.SubSubjectType));

                if (dsTemp != null && dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
                {
                    normalRaidEntity.SubSubjectTypeId = dsTemp.Tables[0].Rows[0][SysParameterTable.C_PARAMETER_VALUE].ToString().Trim();
                }

                normalRaidEntity.WholeSaleMarket = dt.Rows[j][colIndex++].ToString().Trim();
                normalRaidEntity.InvestigationResult = dt.Rows[j][colIndex++].ToString().Trim();
                normalRaidEntity.SubjectNote = dt.Rows[j][colIndex++].ToString().Trim();
                normalRaidEntity.ExecutionResult = dt.Rows[j][colIndex++].ToString().Trim();

                normalRaidEntity.AgencyId = this.ddlAgency.SelectedValue;
                normalRaidEntity.Agency = this.ddlAgency.SelectedItem.Text;

                normalRaidEntity.StatusReportCfjds = 0;
                normalRaidEntity.StatusReportJdbg = 0;
                normalRaidEntity.StatusReportKyqd = 0;
                normalRaidEntity.StatusReportXdbg = 0;
                normalRaidEntity.StatusReportXhzm = 0;
                normalRaidEntity.StatusReportXrzl = 0;

                normalRaidEntity.CreateDate = DateTime.Now;
                normalRaidEntity.CreateUser = base.CurrentUser.SecUserEntity.UserId;

                normalRaidEntity.UserId = ddlUser.SelectedValue;
                normalRaidEntity.UserName = ddlUser.SelectedItem.Text;

                listNormalRaidEntity.Add(normalRaidEntity);
            }

            int total_success_import = 0;
            int total_valid_product = listNormalRaidEntity.Count;
            foreach (NormalRaidEntity entity in listNormalRaidEntity)
            {

                if (MainService.NormalRaidBLLService.InsertNormalRaid(entity, null, null, null, null, true))
                    total_success_import += 1;
            }

            if (total_success_import > 0)
            {
                base.AlertMessage(total_success_import.ToString() + " raids are valid, and import successfully!");
            }
            else
            {
                base.AlertMessage("All raids are invalid. Please check, try it later.");
            }

            #endregion
        }
Ejemplo n.º 7
0
        protected void btnDownload_Click(object sender, EventArgs e)
        {
            if (OtherRaidType == "MarketSweep")
            {
                BPSC.Common.ExcelTemplate excelTemplalte = new BPSC.Common.ExcelTemplate("Market_Sweep_SubDistributor_Template.xls");
                excelTemplalte.Export("Market_Sweep_Investigation_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
            }
            else if (OtherRaidType == "SubRaid")
            {
                BPSC.Common.ExcelTemplate excelTemplalte = new BPSC.Common.ExcelTemplate("Market_Sweep_SubDistributor_Template.xls");
                excelTemplalte.Export("Sub-Distributor_Investigation_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
            }

        }
Ejemplo n.º 8
0
        protected void btnDownloadPriceRecord_Click(object sender, EventArgs e)
        {
            DataTable dt = MainService.ProductPriceRecordBLLService.Query();

            #region Wrap DataTable
            // 
            DataTable dtWrap = new DataTable();
            dtWrap.Columns.Add("Product_ID", typeof(string));
            dtWrap.Columns.Add("GBU", typeof(string));
            dtWrap.Columns.Add("Category", typeof(string));
            dtWrap.Columns.Add("Brand", typeof(string));
            dtWrap.Columns.Add("BrandTpye", typeof(string));
            dtWrap.Columns.Add("Subcategory", typeof(string));
            dtWrap.Columns.Add("Product_Code_SAP_Code", typeof(string));
            dtWrap.Columns.Add("DESC_CN", typeof(string));
            dtWrap.Columns.Add("Product_Type", typeof(string));
            dtWrap.Columns.Add("BrandSize", typeof(string));
            dtWrap.Columns.Add("CasePackage", typeof(string));
            dtWrap.Columns.Add("Reatail_CasePrice", typeof(decimal));
            //dtWrap.Columns.Add("Specification", typeof(string));
            dtWrap.Columns.Add("DESC_EN", typeof(string));
            for (int i = 1; i < 11; i++)
            {
                dtWrap.Columns.Add("NewPrice" + i.ToString(), typeof(string));
            }
            
            DataRow rowWrap = null;
            foreach (DataRow row in dt.Rows)
            {
                rowWrap = dtWrap.NewRow();
                rowWrap["Product_ID"] = row[ProductTable.C_Product_ID];
                rowWrap["GBU"] = row[ProductTable.C_GBU];
                rowWrap["Category"] = row[ProductTable.C_Category];
                rowWrap["Brand"] = row[ProductTable.C_Brand];
                rowWrap["BrandTpye"] = row[ProductTable.C_BrandType];
                rowWrap["Subcategory"] = row[ProductTable.C_SubCategory];
                rowWrap["Product_Code_SAP_Code"] = row[ProductTable.C_Product_SAP_Code];
                rowWrap["DESC_CN"] = row[ProductTable.C_DESC_CN];
                rowWrap["Product_Type"] = row[ProductTable.C_Product_Type];
                rowWrap["BrandSize"] = row[ProductTable.C_Product_Size];
                rowWrap["CasePackage"] = row[ProductTable.C_Case_Package];
                rowWrap["Reatail_CasePrice"] = row[ProductTable.C_Retail_CasePrice];
                //rowWrap["Specification"] = row[ProductTable.C_Specification];
                rowWrap["DESC_EN"] = row[ProductTable.C_DESC_EN];
                for (int i = 1; i < 11; i++)
                {
                    rowWrap["NewPrice" + i.ToString()] = row["NewPrice" + i.ToString()];
                }
                dtWrap.Rows.Add(rowWrap);
            }
            #endregion

            BPSC.Common.ExcelTemplate excelTemplalte = new BPSC.Common.ExcelTemplate("Product_PriceRecord_Template.xls");
            excelTemplalte.Export(dtWrap, "ProductPriceRecord".Replace(' ', '_') + "_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
        }
Ejemplo n.º 9
0
        protected void btnDownload_Click(object sender, EventArgs e)
        {
            DataTable dt = QueryData();

            #region Wrap DataTable
            DataTable dtWrap = new DataTable();
            dtWrap.Columns.Add("Product_ID", typeof(string));
            dtWrap.Columns.Add("GBU", typeof(string));
            dtWrap.Columns.Add("Category", typeof(string));
            dtWrap.Columns.Add("Brand", typeof(string));
            dtWrap.Columns.Add("BrandTpye", typeof(string));
            dtWrap.Columns.Add("Subcategory", typeof(string));
            dtWrap.Columns.Add("Product_Code_SAP_Code", typeof(string));
            dtWrap.Columns.Add("DESC_CN", typeof(string));
            dtWrap.Columns.Add("Product_Type", typeof(string));
            dtWrap.Columns.Add("BrandSize", typeof(string));
            dtWrap.Columns.Add("CasePackage", typeof(string));
            dtWrap.Columns.Add("Reatail_CasePrice", typeof(decimal));            
            dtWrap.Columns.Add("DESC_EN", typeof(string));
            dtWrap.Columns.Add("Specification", typeof(string));
            dtWrap.Columns.Add("Product_StartDate", typeof(string));
            dtWrap.Columns.Add("Product_EndDate", typeof(string));

            DataRow rowWrap = null;
            foreach (DataRow row in dt.Rows)
            {
                rowWrap = dtWrap.NewRow();
                rowWrap["Product_ID"] = row[ProductTable.C_Product_ID];
                rowWrap["GBU"] = row[ProductTable.C_GBU];
                rowWrap["Category"] = row[ProductTable.C_Category];
                rowWrap["Brand"] = row[ProductTable.C_Brand];
                rowWrap["BrandTpye"] = row[ProductTable.C_BrandType];
                rowWrap["Subcategory"] = row[ProductTable.C_SubCategory];
                rowWrap["Product_Code_SAP_Code"] = row[ProductTable.C_Product_SAP_Code];
                rowWrap["DESC_CN"] = row[ProductTable.C_DESC_CN];
                rowWrap["Product_Type"] = row[ProductTable.C_Product_Type];
                rowWrap["BrandSize"] = row[ProductTable.C_Product_Size];
                rowWrap["CasePackage"] = row[ProductTable.C_Case_Package];
                rowWrap["Reatail_CasePrice"] = row[ProductTable.C_Retail_CasePrice];
                rowWrap["DESC_EN"] = row[ProductTable.C_DESC_EN];
                rowWrap["Specification"] = row[ProductTable.C_Specification];
                rowWrap["Product_StartDate"] = row[ProductTable.C_Product_StartDate];
                rowWrap["Product_EndDate"] = row[ProductTable.C_Product_EndDate];
                dtWrap.Rows.Add(rowWrap);
            }
            #endregion

            //BPS.Common.ExcelHelper.ExportToCsvFile(this, dt, ActivityName, ActivityName + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"));

            BPSC.Common.ExcelTemplate excelTemplalte = new BPSC.Common.ExcelTemplate("Product_Import_Template.xls");
            excelTemplalte.Export(dtWrap, "ProductData".Replace(' ', '_') + "_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
        }