override protected Boolean LoadData() { try { // Load Data For Page. DAProducer daProducer = new DAProducer(); daProducer.USP_Producer_GetFullID(this.KeyID); // fProducerName.Value = daProducer.fProducerName.ToString(); fDescription.Value = daProducer.fDescription.ToString(); fLogoLink.ImageUrl = "~" + daProducer.fLogoLink.ToString(); fWebsite.Value = daProducer.fWebsite.ToString(); // // Khi cần enabled cột nào //if (this.KeyID > 0) //{ // if (mode != Act.Clone) // fUserName.Enabled = false; // else // fUserName.Text = ""; //} } catch (Exception e) { ShowErrorMes("Lỗi hệ thống: " + e.ToString()); return(false); } return(true); }
private DAProducer CreateObjectFromPage() { // check DAProducer daProducer = new DAProducer(); // daProducer.fProducerName = fProducerName.Value.Trim(); daProducer.fDescription = fDescription.Value.Trim(); HttpPostedFile file = inputFile.PostedFile; if (file != null && file.ContentLength > 0) { //Delete old file Utils.DeleteFile(fLogoLink.ImageUrl, Server); daProducer.fLogoLink = Utils.UploadImage(file, Server, "~/Media/Producer"); } else { daProducer.fLogoLink = fLogoLink.ImageUrl.Replace("~", ""); } fLogoLink.ImageUrl = "~" + daProducer.fLogoLink; daProducer.fWebsite = fWebsite.Value.Trim(); // return(daProducer); }
override protected int DeleteByID(int pID) { try { DAProducer DAProducer = new DAProducer(); DAProducer.USP_Producer_Delete(pID); return(1); } catch { return(0); } }
override protected int ExecUpdate() { // Update with ID = this.ID try { DAProducer DAProducer = CreateObjectFromPage(); DAProducer.fID = this.KeyID; DAProducer.USP_Producer_Update(); return(1); } catch { return(0); } }
override protected int ExecInsert() { try { DAProducer DAProducer = CreateObjectFromPage(); if (this.mode == ActParam.New) { DAProducer.fID = DAProducer.USP_GetKey(); this.KeyID = DAProducer.fID; // --> Update new SessionID for continue edit. } else { DAProducer.fID = 0; } DAProducer.USP_Producer_Insert(); return(1); } catch { return(0); } }
override protected Boolean GetDataComboBox() { try { DAProducer daProducer = new DAProducer(); fProducerID.DataSource = daProducer.USP_Producer_GetDataForComboBox(); fProducerID.DataBind(); DAVAT daVAT = new DAVAT(); fVATID.DataSource = daVAT.USP_VAT_GetDataForComboBox(); fVATID.DataBind(); return(true); } catch (Exception ex) { ShowErrorMes("Lỗi hệ thống: " + ex.Message); return(false); } }
private void CreateTemplate() { // change this line to contain the path to the output folder DirectoryInfo outputDir = new DirectoryInfo(@"c:\"); if (!outputDir.Exists) { throw new Exception("outputDir does not exist!"); } FileInfo newFile = new FileInfo(Server.MapPath("Media/Demo/Excel/templatev1.0.xlsx")); if (newFile.Exists) { newFile.Delete(); // ensures we create a new workbook newFile = new FileInfo(Server.MapPath("Media/Demo/Excel/templatev1.0.xlsx")); } using (ExcelPackage package = new ExcelPackage(newFile)) { // add a new worksheet to the empty workbook ExcelWorksheet workSheet = package.Workbook.Worksheets.Add(EnumProduct.productSheet); ExcelWorksheet categorySheet = package.Workbook.Worksheets.Add(EnumProduct.productCatSheet); ExcelWorksheet producerSheet = package.Workbook.Worksheets.Add(EnumProduct.producerSheet); ExcelWorksheet VATSheet = package.Workbook.Worksheets.Add(EnumProduct.VATSheet); //Add the headers ArrayList headers = new ArrayList { EnumProduct.fProductName, EnumProduct.fDescription, EnumProduct.fProductCode, EnumProduct.fUnitName, //EnumProduct.fUnitID, EnumProduct.fProducer, EnumProduct.fProducerID, EnumProduct.fPrice, EnumProduct.fSalePrice, EnumProduct.fSchSalePrice, //EnumProduct.fScheSaleFrom, //EnumProduct.fScheSaleTo, EnumProduct.fVAT, EnumProduct.fVATID, //EnumProduct.fImgLink1, //EnumProduct.fImgLink2, //EnumProduct.fImgLink3, //EnumProduct.fImgLink4, //EnumProduct.fImgLink5, EnumProduct.fProductCat1, EnumProduct.fProductCatID1, EnumProduct.fProductCat2, EnumProduct.fProductCatID2, EnumProduct.fProductCat3, EnumProduct.fProductCatID3, EnumProduct.fProductCat4, EnumProduct.fProductCatID4, EnumProduct.fProductCat5, EnumProduct.fProductCatID5, EnumProduct.fIsManagerQuantity, EnumProduct.fQuantity, EnumProduct.fNumSaled, EnumProduct.fRewriteURL, EnumProduct.fPageTitle, EnumProduct.fMetaTitle, EnumProduct.fMetaDescription, EnumProduct.fMetaKeywords, EnumProduct.fTags, EnumProduct.fDesShort, EnumProduct.fDesBeforPrice, EnumProduct.fDesAfterPrice, EnumProduct.fIsNewProduct, EnumProduct.fIsShow, EnumProduct.fIsHiddenWhenOutoff, EnumProduct.fIsShowYouSaving, EnumProduct.fBuyButtonText, EnumProduct.fShowInProductTyleID, EnumProduct.fMinOrder, EnumProduct.fMaxForWarrning, EnumProduct.fBonusPoint, EnumProduct.fPos, EnumProduct.fIsAllowComment }; for (int j = 0; j < headers.Count; j++) { workSheet.Cells[1, j + 1].Value = headers[j]; } //get the categories DAProductCat producCat = new DAProductCat(); List <DAProductCat> productCats = producCat.USP_ProductCat_GetList(0, 0); //add category to Category sheet int i = 1; foreach (DAProductCat productCat in productCats) { categorySheet.Cells["A" + i].Value = productCat.fProductCat; categorySheet.Cells["B" + i].Value = productCat.fID; i++; } //set category to main sheet setSelectListCell(workSheet, headers, EnumProduct.productCatSheet, EnumProduct.fProductCat1, EnumProduct.fProductCatID1, productCats.Count); setSelectListCell(workSheet, headers, EnumProduct.productCatSheet, EnumProduct.fProductCat2, EnumProduct.fProductCatID2, productCats.Count); setSelectListCell(workSheet, headers, EnumProduct.productCatSheet, EnumProduct.fProductCat3, EnumProduct.fProductCatID3, productCats.Count); setSelectListCell(workSheet, headers, EnumProduct.productCatSheet, EnumProduct.fProductCat4, EnumProduct.fProductCatID4, productCats.Count); setSelectListCell(workSheet, headers, EnumProduct.productCatSheet, EnumProduct.fProductCat5, EnumProduct.fProductCatID5, productCats.Count); //get list producer DAProducer daProducer = new DAProducer(); List <DAProducer> producers = daProducer.USP_Producer_GetList(0, 0); //add producer to 'Nhà sàn xuất' sheet i = 1; foreach (DAProducer producer in producers) { producerSheet.Cells["A" + i].Value = producer.fProducerName; producerSheet.Cells["B" + i].Value = producer.fID; i++; } //set producer to main sheet setSelectListCell(workSheet, headers, EnumProduct.producerSheet, EnumProduct.fProducer, EnumProduct.fProducerID, producers.Count); //get list VAT DAVAT daVAT = new DAVAT(); List <DAVAT> VATs = daVAT.USP_VAT_GetList(0, 0); //add VAT to 'Thuế' sheet i = 1; foreach (DAVAT VAT in VATs) { VATSheet.Cells["A" + i].Value = VAT.fVATName; VATSheet.Cells["B" + i].Value = VAT.fID; i++; } //set VAT to main sheet setSelectListCell(workSheet, headers, EnumProduct.VATSheet, EnumProduct.fVAT, EnumProduct.fVATID, producers.Count); //set checkbox sheet setYesNoCell(workSheet, headers, EnumProduct.fIsManagerQuantity); setYesNoCell(workSheet, headers, EnumProduct.fIsNewProduct); setYesNoCell(workSheet, headers, EnumProduct.fIsShow); setYesNoCell(workSheet, headers, EnumProduct.fIsHiddenWhenOutoff); setYesNoCell(workSheet, headers, EnumProduct.fIsShowYouSaving); setYesNoCell(workSheet, headers, EnumProduct.fIsAllowComment); //set Data format cell //setDatetimeCell(workSheet, headers, EnumProduct.fScheSaleFrom); //setDatetimeCell(workSheet, headers, EnumProduct.fScheSaleTo); //set style workSheet.Cells["A1:AR100"].Style.Border.Top.Style = ExcelBorderStyle.Thin; workSheet.Cells["A1:AR100"].Style.Border.Bottom.Style = ExcelBorderStyle.Thin; workSheet.Cells["A1:AR100"].Style.Border.Left.Style = ExcelBorderStyle.Thin; workSheet.Cells["A1:AR100"].Style.Border.Right.Style = ExcelBorderStyle.Thin; var range = workSheet.Cells["A1:AR100"]; var table = workSheet.Tables.Add(range, "tablename"); table.TableStyle = TableStyles.Medium9; workSheet.Cells[workSheet.Dimension.Address].AutoFitColumns(); //set sheet property // set some document properties package.Workbook.Properties.Title = "Danh sách sản phẩm"; package.Workbook.Properties.Author = "Tuan Anh"; package.Workbook.Properties.Comments = "This sample demonstrates how to create an Excel 2007 workbook using EPPlus"; // set some extended property values package.Workbook.Properties.Company = "TMA Solutions"; // set some custom property values package.Workbook.Properties.SetCustomPropertyValue("Checked by", "Jan Källman"); package.Workbook.Properties.SetCustomPropertyValue("AssemblyName", "EPPlus"); // save our new workbook and we are done! //Hide id columns workSheet.Column((headers.IndexOf(EnumProduct.fProducerID) + 1)).Hidden = true; workSheet.Column((headers.IndexOf(EnumProduct.fVATID) + 1)).Hidden = true; workSheet.Column((headers.IndexOf(EnumProduct.fProductCatID1) + 1)).Hidden = true; workSheet.Column((headers.IndexOf(EnumProduct.fProductCatID2) + 1)).Hidden = true; workSheet.Column((headers.IndexOf(EnumProduct.fProductCatID3) + 1)).Hidden = true; workSheet.Column((headers.IndexOf(EnumProduct.fProductCatID4) + 1)).Hidden = true; workSheet.Column((headers.IndexOf(EnumProduct.fProductCatID5) + 1)).Hidden = true; //Hide other sheet except main sheet categorySheet.Hidden = eWorkSheetHidden.Hidden; producerSheet.Hidden = eWorkSheetHidden.Hidden; VATSheet.Hidden = eWorkSheetHidden.Hidden; package.Save(); } }