public MainWindow(User user) { InitializeComponent(); MainWindow.user = user; userName.Text = MainWindow.user.username; if (MainWindow.user.admin) { userPermissions.Text = "Administrator"; } else { userPermissions.Text = "User"; } m_dashboard = new Dashboard(); m_invoice = new InvoiceMain(); m_receipt = new ReceiptMain(); m_creditNote = new CreditNoteMain(); m_statement = new StatementMain(this); m_product = new ProductMain(); m_customer = new CustomerMain(); m_quote = new QuoteMain(); m_expenses = new ExpensesMain(); m_settings = new SettingsMain(); m_order = new OrderMain(this); BtnDashboard_Click(null, null); }
private void homePage_Click(object sender, RoutedEventArgs e) { this.controlGrid.Children.Clear(); ProductMain products = new ProductMain(); this.addUIElement(products); this.bringToFront(products); products.refreshData(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { username.Content = AuthenticatedUser.user.userName; ProductMain products = new ProductMain(); this.addUIElement(products); this.bringToFront(products); products.refreshData(); }
public ActionResult GetMain(ProductViewModel pvm) { ProductMain_Data data = new ProductMain_Data(); ProductMain store = ProductService.GetMain(pvm.Salepage_id); data = store.Data; if (data != default(ProductMain_Data)) { pvm.ProductName = data.Title; pvm.UnitPrice = data.Price; var currentProduct = ProductService.GetCurrentProducts(); currentProduct.AddProduct(pvm); return(Json(store)); } else { return(Json("")); } }
public static ProductMain GetMain(int salepage_id) { var client = new RestClient("https://apigw.qa.91dev.tw/ec/V1/SalePage/GetMain"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Connection", "keep-alive"); request.AddHeader("Content-Length", "21"); request.AddHeader("Accept-Encoding", "gzip, deflate"); request.AddHeader("Host", "apigw.qa.91dev.tw"); request.AddHeader("Cache-Control", "no-cache"); request.AddHeader("x-api-key", keyValue); request.AddHeader("Content-Type", "application/json"); request.AddParameter("undefined", "{\r\n \"id\": " + salepage_id + "\r\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ProductMain store = Newtonsoft.Json.JsonConvert.DeserializeObject <ProductMain>(response.Content); return(store); }
//Marius private void Product_Load(object sender, EventArgs e) { try { List <LTS.Product> prod = new List <LTS.Product>(); prod = DAT.DataAccess.GetProduct().ToList(); for (int i = 0; i < prod.Count; i++) { ProductMain pmThis = new ProductMain(); pmThis.ProductID = prod[i].ProductID; pmThis.ProductName = prod[i].ProductName; pmThis.ProductDescription = prod[i].ProductDescription; pmThis.CategoryID = prod[i].CategoryID; pmThis.BrandID = prod[i].BrandID; pmThis.BarcodeID = prod[i].BarcodeID; pmThis.amountItems = DAT.DataAccess.GetItem().Where(u => u.ProductID == pmThis.ProductID && u.ItemStatus == true).ToList().Count; LTS.Category c = DAT.DataAccess.GetCategory().Where(o => o.CategoryID == prod[i].CategoryID).FirstOrDefault(); pmThis.CategoryName = c.CategoryName; pmThis.CategoryDescription = c.CategoryDescription; LTS.Brand b = DAT.DataAccess.GetBrand().Where(o => o.BrandID == prod[i].BrandID).FirstOrDefault(); pmThis.BrandName = b.BrandName; pmThis.BrandDescription = b.BrandDescription; LTS.Barcode bar = DAT.DataAccess.GetBarcode().Where(o => o.BarcodeID == prod[i].BarcodeID).FirstOrDefault(); pmThis.BarcodeNumber = bar.BarcodeNumber; pm.Add(pmThis); dgvProducts.Rows.Add(pmThis.ProductID, pmThis.ProductName, pmThis.ProductDescription, pmThis.BarcodeNumber, pmThis.BrandName, pmThis.CategoryName, pmThis.amountItems); } dgvProducts.ClearSelection(); } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
public ProductMain GetProductMain(Sender sender, Guid ProductID) { try { using (ObjectProxy op = new ObjectProxy()) { ProductMain obj = new ProductMain(); obj.ProductID = ProductID; if (op.LoadProductMainByProductID(obj) == 0) { return(null); } return(obj); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
private void dgvUpdateProduct_SelectionChanged(object sender, EventArgs e) { try { if (dgvUpdateProduct.SelectedRows.Count == 1) { int index = dgvUpdateProduct.SelectedRows[0].Index; ProductMain p = new ProductMain(); p = pm[index]; current = p; lblProdID.Text = p.ProductID.ToString(); tbProdName.Text = p.ProductName.ToString(); tbProdDescr.Text = p.ProductDescription.ToString(); tbBarcode.Text = p.BarcodeNumber.ToString(); LTS.Category cat = new LTS.Category(); cat = listC.Where(o => o.CategoryID == p.CategoryID).FirstOrDefault(); if (cat != null) { int catIndex = listC.IndexOf(cat); cbCategoryName.SelectedIndex = catIndex; } LTS.Brand brand = new LTS.Brand(); brand = listB.Where(z => z.BrandID == p.BrandID).FirstOrDefault(); if (brand != null) { int brandInd = listB.IndexOf(brand); cbBrandName.SelectedIndex = brandInd; } } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
public void SaveProduct() { try { using (ProxyBE op = new ProxyBE()) { //存储文件路径:根目录/CompanyID/Products/yyyyMM/ProductCode/FileType string RootPath = "";// Config.StorageFolder; RootPath = Path.Combine(RootPath, "Products"); RootPath = Path.Combine(RootPath, DateTime.Now.ToString("yyyyMM")); RootPath = Path.Combine(RootPath, parm.ProductCode); if (!Directory.Exists(RootPath)) { Directory.CreateDirectory(RootPath); } string ServerPath = Server.MapPath("/"); SaveProductArgs args = new SaveProductArgs(); List <ProductProcessFile> ProcessFiles = new List <ProductProcessFile>(); #region 处理主表 //主图片数据 string HeardImg = (ServerPath + Request["HeadImgUrl"].ToString().Replace("/", "\\")).Replace("\\\\", "\\"); if (!File.Exists(HeardImg)) { throw new Exception("上传的图片文件损坏,请重新上传。"); } //保存图片文件 string heardimg_savepath = Path.Combine(RootPath, "HeardImg\\" + parm.ProductCode + Path.GetExtension(HeardImg)); //if (!Directory.Exists(Path.GetDirectoryName(heardimg_savepath))) //{ // Directory.CreateDirectory(Path.GetDirectoryName(heardimg_savepath)); //} // UploadFile(HeardImg, heardimg_savepath); //File.Copy(HeardImg, heardimg_savepath, true); ProductMain main = op.Client.GetProductMain(SenderUser, parm.ProductID); if (main == null) { main = new ProductMain(); main.ProductID = parm.ProductID; } main.ProductCode = parm.ProductCode; main.ProductName = parm.ProductName; main.CategoryID = parm.CategoryID; main.Color = parm.Color; main.Size = parm.Size; main.MaterialStyle = parm.MaterialStyle; main.MaterialCategory = parm.MaterialCategory; main.Price = parm.Price; main.Remark = ""; main.ImageUrl = heardimg_savepath; //检查ProductCode 是否已经存在 ProductMain temp = op.Client.GetProductMainByProductCode(SenderUser, parm.ProductCode); if (temp != null && temp.ProductID != main.ProductID) { throw new PException("产品编号【{0}】已经存在,请重新编号。", parm.ProductCode); } args.ProductMain = main; #endregion #region 处理BOM表 string BOMFilePath = (ServerPath + Request["BOMFileUrl"].ToString().Replace("/", "\\")).Replace("\\\\", "\\"); if (!File.Exists(BOMFilePath)) { throw new Exception("上传的BOM文件损坏,请重新上传。"); } //开始解析BOM表 List <ProductDetail> list_ProductDetails = ImportBOM(BOMFilePath, main.ProductID); if (list_ProductDetails.Count == 0) { throw new Exception("上传的BOM文件数据有误,请重新上传。"); } args.ProductDetails = list_ProductDetails; //保存BOM表 string bom_savepath = Path.Combine(RootPath, "BOM\\" + parm.ProductCode + Path.GetExtension(BOMFilePath)); //if (!Directory.Exists(Path.GetDirectoryName(bom_savepath))) //{ // Directory.CreateDirectory(Path.GetDirectoryName(bom_savepath)); //} //File.Copy(BOMFilePath, bom_savepath, true); UploadFile(BOMFilePath, bom_savepath); ProductProcessFile pf = new ProductProcessFile(); pf.ProductID = parm.ProductID; pf.FileID = Guid.NewGuid(); pf.FileName = Path.GetFileName(bom_savepath); pf.FilePath = bom_savepath; pf.FileType = "BOM"; ProcessFiles.Add(pf); #endregion #region 处理五金表 string HardwareFilePath = (ServerPath + Request["HardwareFileUrl"].ToString().Replace("/", "\\")).Replace("\\\\", "\\");; if (!File.Exists(HardwareFilePath)) { throw new Exception("上传的五金文件损坏,请重新上传。"); } //开始解析五金表 List <Product2Hardware> list_HardwareDetails = ImportHardwareExcel(HardwareFilePath, main.ProductID); if (list_ProductDetails.Count == 0) { throw new Exception("上传的五金文件数据有误,请重新上传。"); } args.Product2Hardwares = list_HardwareDetails; //保存五金表 string hardware_savepath = Path.Combine(RootPath, "HardwareBOM\\" + parm.ProductCode + Path.GetExtension(HardwareFilePath)); //if (!Directory.Exists(Path.GetDirectoryName(hardware_savepath))) //{ // Directory.CreateDirectory(Path.GetDirectoryName(hardware_savepath)); //} //File.Copy(HardwareFilePath, hardware_savepath, true); UploadFile(HardwareFilePath, hardware_savepath); pf = new ProductProcessFile(); pf.ProductID = parm.ProductID; pf.FileID = Guid.NewGuid(); pf.FileName = Path.GetFileName(hardware_savepath); pf.FilePath = hardware_savepath; pf.FileType = "Hardware"; ProcessFiles.Add(pf); #endregion #region 处理加工文件 if (string.IsNullOrEmpty(Request["CNCFileUrl"])) { throw new Exception("上传的CNC文件损坏,请重新上传。"); } string[] cnc_files = Request["CNCFileUrl"].ToString().Split(','); foreach (string cnc_File in cnc_files) { string SourceFile = (ServerPath + cnc_File.Replace("/", "\\")).Replace("\\\\", "\\");; string savepath = Path.Combine(RootPath, "ProcessFile\\" + Path.GetFileName(cnc_File)); //if (!Directory.Exists(Path.GetDirectoryName(savepath))) //{ // Directory.CreateDirectory(Path.GetDirectoryName(savepath)); //} //if (File.Exists(savepath)) //{ // File.Delete(savepath); //} //File.Copy(SourceFile, savepath, true); UploadFile(SourceFile, savepath); pf = new ProductProcessFile(); pf.ProductID = parm.ProductID; pf.FileID = Guid.NewGuid(); pf.FileName = Path.GetFileName(savepath); pf.FilePath = savepath; if (Path.GetExtension(savepath).ToLower() == ".dxf") { pf.FileType = "DXF"; } else { pf.FileType = "CNC"; } ProcessFiles.Add(pf); } #endregion #region 处理图纸文件 string[] drawing_files = Request["DrawingFileUrl"].ToString().Split(','); foreach (string drawing_File in drawing_files) { string SourceFile = (ServerPath + drawing_File.Replace("/", "\\")).Replace("\\\\", "\\");; string savepath = Path.Combine(RootPath, "DrawingFile\\" + Path.GetFileName(drawing_File)); //if (!Directory.Exists(Path.GetDirectoryName(savepath))) //{ // Directory.CreateDirectory(Path.GetDirectoryName(savepath)); //} //if (File.Exists(savepath)) //{ // File.Delete(savepath); //} //File.Copy(SourceFile, savepath, true); UploadFile(SourceFile, savepath); pf = new ProductProcessFile(); pf.ProductID = parm.ProductID; pf.FileID = Guid.NewGuid(); pf.FileName = Path.GetFileName(savepath); pf.FilePath = savepath; pf.FileType = "DrawingFile"; ProcessFiles.Add(pf); } #endregion #region 处理效果文件 string[] rendering_files = Request["DrawingFileUrl"].ToString().Split(','); foreach (string rendering_File in rendering_files) { string SourceFile = (ServerPath + rendering_File.Replace("/", "\\")).Replace("\\\\", "\\");; string savepath = Path.Combine(RootPath, "RenderingFile\\" + Path.GetFileName(rendering_File)); //if (!Directory.Exists(Path.GetDirectoryName(savepath))) //{ // Directory.CreateDirectory(Path.GetDirectoryName(savepath)); //} //if (File.Exists(savepath)) //{ // File.Delete(savepath); //} //File.Copy(SourceFile, savepath, true); UploadFile(SourceFile, savepath); pf = new ProductProcessFile(); pf.ProductID = parm.ProductID; pf.FileID = Guid.NewGuid(); pf.FileName = Path.GetFileName(savepath); pf.FilePath = savepath; pf.FileType = "RenderingFile"; ProcessFiles.Add(pf); } #endregion args.ProductProcessFiles = ProcessFiles; op.Client.SaveProduct(SenderUser, args); WriteSuccess(); } } catch (Exception ex) { PLogger.LogError(ex); WriteError(ex.Message, ex); } finally { string RootPath = Server.MapPath(@"/temp/"); RootPath += DateTime.Now.ToString("yyyyMMdd") + "\\"; string ProductID = Request["ProductID"]; if (ProductID != null) { RootPath += ProductID; } if (Directory.Exists(RootPath)) { Directory.Delete(RootPath, true); } } }
//Marius private void UpdateProduct_Load(object sender, EventArgs e) { try { listBar = DAT.DataAccess.GetBarcode().ToList(); listB = new List <LTS.Brand>(); listB = DAT.DataAccess.GetBrand().ToList(); for (int a = 0; a < listB.Count; a++) { Brand.Add(listB[a].BrandName); } listC = new List <LTS.Category>(); listC = DAT.DataAccess.GetCategory().ToList(); for (int b = 0; b < listC.Count; b++) { Category.Add(listC[b].CategoryName); } cbBrandName.DataSource = Brand; cbCategoryName.DataSource = Category; lblBarVal.Visible = false; lblDesVal.Visible = false; lblNameVal.Visible = false; List <LTS.Product> prod = new List <LTS.Product>(); prod = DAT.DataAccess.GetProduct().ToList(); for (int i = 0; i < prod.Count; i++) { ProductMain pmThis = new ProductMain(); pmThis.ProductID = prod[i].ProductID; pmThis.ProductName = prod[i].ProductName; pmThis.ProductDescription = prod[i].ProductDescription; pmThis.CategoryID = prod[i].CategoryID; pmThis.BrandID = prod[i].BrandID; pmThis.BarcodeID = prod[i].BarcodeID; pmThis.amountItems = DAT.DataAccess.GetItem().Where(u => u.ProductID == pmThis.ProductID && u.ItemStatus == true).ToList().Count; LTS.Category c = DAT.DataAccess.GetCategory().Where(o => o.CategoryID == prod[i].CategoryID).FirstOrDefault(); pmThis.CategoryName = c.CategoryName; pmThis.CategoryDescription = c.CategoryDescription; LTS.Brand b = DAT.DataAccess.GetBrand().Where(o => o.BrandID == prod[i].BrandID).FirstOrDefault(); pmThis.BrandName = b.BrandName; pmThis.BrandDescription = b.BrandDescription; LTS.Barcode bar = DAT.DataAccess.GetBarcode().Where(o => o.BarcodeID == prod[i].BarcodeID).FirstOrDefault(); pmThis.BarcodeNumber = bar.BarcodeNumber; pm.Add(pmThis); dgvUpdateProduct.Rows.Add(pmThis.ProductID, pmThis.ProductName, pmThis.ProductDescription, pmThis.BarcodeNumber, pmThis.BrandName, pmThis.CategoryName, pmThis.amountItems); } foreach (DataGridViewColumn column in dgvUpdateProduct.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
private void metroTile1_Click(object sender, EventArgs e) { ProductMain frm = new ProductMain(); frm.ShowDialog(); }
public void SaveProduct(Sender sender, SaveProductArgs args) { try { using (ObjectProxy op = new ObjectProxy(true)) { ProductMain obj = new ProductMain(); obj.ProductID = args.ProductMain.ProductID; if (op.LoadProductMainByProductID(obj) == 0) { args.ProductMain.Created = DateTime.Now; args.ProductMain.CreatedBy = sender.UserCode + "." + sender.UserName; args.ProductMain.Modified = DateTime.Now; args.ProductMain.ModifiedBy = sender.UserCode + "." + sender.UserName; op.InsertProductMain(args.ProductMain); } else { args.ProductMain.Modified = DateTime.Now; args.ProductMain.ModifiedBy = sender.UserCode + "." + sender.UserName; op.UpdateProductMainByProductID(args.ProductMain); } if (args.Product2Hardwares != null) { op.DeleteProduct2HardwaresByProductID(args.ProductMain.ProductID); foreach (Product2Hardware item in args.Product2Hardwares) { item.Created = DateTime.Now; item.CreatedBy = sender.UserCode + "." + sender.UserName; item.Modified = DateTime.Now; item.ModifiedBy = sender.UserCode + "." + sender.UserName; op.InsertProduct2Hardware(item); } } if (args.ProductDetails != null) { op.DeleteProductDetailsByProductID(args.ProductMain.ProductID); foreach (ProductDetail item in args.ProductDetails) { if (IsProductBarcodeDuplicated(sender, item)) { throw new PException("产品条码【{0}】已存在。", item.BarcodeNo); } item.Created = DateTime.Now; item.CreatedBy = sender.UserCode + "." + sender.UserName; item.Modified = DateTime.Now; item.ModifiedBy = sender.UserCode + "." + sender.UserName; op.InsertProductDetail(item); } } if (args.ProductProcessFiles != null) { op.DeleteProductProcessFilesByProductID(args.ProductMain.ProductID); foreach (ProductProcessFile item in args.ProductProcessFiles) { item.Created = DateTime.Now; item.CreatedBy = sender.UserCode + "." + sender.UserName; item.Modified = DateTime.Now; item.ModifiedBy = sender.UserCode + "." + sender.UserName; op.InsertProductProcessFile(item); } } op.CommitTransaction(); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }