private void btnLeft_Click(object sender, EventArgs e) { foreach (Control ctr in flpAllitems.Controls) { if (ctr.BackColor == Color.FromArgb(0, 102, 204)) { UCMenuAdd ucMenuGet = (UCMenuAdd)ctr; ProductionModel itemlef = (ProductionModel)(ucMenuGet.Tag); ProductionModel item = new ProductionModel(); item.ProductID = itemlef.ProductID; item.ProductNameDesc = itemlef.ProductNameDesc; listmap.Add(item); var index = -1; for(int i=0;i<listall.Count;i++) { if (listall[i].ProductID == item.ProductID) { index = i; } } if (index> - 1) { listall.RemoveAt(index); } } } LoadThisGroupItems(); LoadAllItem(); }
private void btnSave_Click(object sender, EventArgs e) { frmConfirm frmcon = new frmConfirm("Messenger", "Do you want edit info price of product ?"); frmcon.ShowDialog(); if (frmcon.DialogResult == System.Windows.Forms.DialogResult.OK) { Button btn = (Button)sender; PriceListModel dataPriceList = (PriceListModel)(btn.Tag); var txtPrice = txtProductPrice.Text; var txtName = txtProductName.Text; var comboColor = cbColor.Text; string message_error = ""; if (txtPrice == "") { message_error = "Price is not empty"; } if (txtName == "") { message_error = "Name is not empty"; } if (message_error == "") { dataPriceList.CurrentPrice = Convert.ToDouble(txtPrice)*1000; dataPriceList.NameDesc = txtName; if(comboColor == ""){ dataPriceList.Color = dataPriceList.Color; } else { dataPriceList.Color = comboColor; } var result = 0; if (dataPriceList.Type == "MODIFIRE") { ModifireModel modifire = new ModifireModel(); modifire.ModifireID = dataPriceList.ID; modifire.CurrentPrice = dataPriceList.CurrentPrice; modifire.ModifireName = dataPriceList.NameDesc; modifire.Color = dataPriceList.Color; result = ModifireService.Created(modifire); } else { ProductionModel product = new ProductionModel(); product.ProductID = dataPriceList.ID; product.CurrentPrice = dataPriceList.CurrentPrice; product.ProductNameDesc = dataPriceList.NameDesc; product.ProductNameSort = dataPriceList.NameSort; product.Color = dataPriceList.Color; result = ProductService.Created(product); } if (result == 1) { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { frmMessager frmMessager = new frmMessager("Edit Product Price", "Error"); frmOpacity.ShowDialog(this, frmMessager); this.Hide(); } } else { frmMessager frmMessager = new frmMessager("Edit Product Price", message_error); frmOpacity.ShowDialog(this, frmMessager); } } }
private void ucItemList_btnSave_Click(object sender, EventArgs e) { try { Button product = (Button)sender; ProductionModel dataProduct = (ProductionModel)(product.Tag); string messageError = ""; var ucItemList = (UCItemList)pnDetail.Controls[0]; var productNameDesc = ucItemList.txtNameDesc.Text; var productNameSort = ucItemList.txtNameSort.Text; var productPrice = Convert.ToDouble(ucItemList.txtPrice.Text) * 1000; var productColor = ucItemList.cbProductColor.Text; if (dataProduct == null) { dataProduct = new ProductionModel(); } if (productNameDesc == "") { messageError += "Product name desc isn't empty."; } if (productNameSort == "") { messageError += "Product name sort isn't empty."; } if (productColor == "") { messageError += "Product Color isn't empty"; } if (productPrice.ToString() == "") { messageError += "Product price isn't empty"; } if (messageError == "") { dataProduct.ProductNameDesc = productNameDesc; dataProduct.ProductNameSort = productNameSort; dataProduct.Color = productColor; dataProduct.CurrentPrice = productPrice; var result = ProductService.Created(dataProduct); var message = ""; if (result == 1) { addItemList("Item List", 3, this.CurrentPage); pnDetail.Controls.Clear(); message = "Save Product Successful."; } else { if (result == -1) { message = "Product name already exist. Please change product name."; } else { message = "Save product fail."; } } frmMessager frm_item = new frmMessager("Messenger", message); frmOpacity.ShowDialog(this, frm_item); } else { frmMessager frm_item = new frmMessager("Messenger", messageError); frmOpacity.ShowDialog(this, frm_item); } } catch (Exception ex) { SystemLog.LogPOS.WriteLog("frmMenuSetting:::::::::::::::::::::::::::ucItemList_btnSave_Click::::::::::::::::::" + ex.Message); } }
private void addItemListDetail(ProductionModel productData) { //pnDetail.Controls.Clear(); if (productData.ProductID > 0) { UCItemList ucItemList = new UCItemList(); if (pnDetail.Controls.Count > 0) { ucItemList = (UCItemList)pnDetail.Controls[0]; } else { ucItemList.Dock = DockStyle.Fill; pnDetail.Controls.Add(ucItemList); } ucItemList.lbProductName.Text = productData.ProductNameDesc; ucItemList.txtNameDesc.Text = productData.ProductNameDesc; ucItemList.txtNameSort.Text = productData.ProductNameSort; ucItemList.txtPrice.Text =money.Format2((productData.CurrentPrice.ToString())); ucItemList.btnSave.Tag = productData; ucItemList.btnSave.Click += ucItemList_btnSave_Click; ucItemList.btnRemove.Click += ucItemList_btnRemove_Click; ucItemList.btnRemove.Tag = productData; ucItemList.btnAddProtions.Visible = false; ucItemList.lbPortions.Visible = false; ucItemList.Tag = productData; ucItemList.flpItemList.Controls.Clear(); ucItemList.addUcMenuGroup(productData.ProductID, 1); ucItemList.cbProductColor.SelectedItem = productData.Color; } else { pnDetail.Controls.Clear(); } }
public int Created(ProductionModel data) { try { if (data.ProductID == 0) { var checkdata = _context.PRODUCTs.Where(x => x.ProductNameDesc == data.ProductNameDesc).ToList(); if (checkdata.Count() > 0) { return -1; } var new_data = new PRODUCT(); new_data.ProductNameDesc = data.ProductNameDesc; new_data.ProductNameSort = data.ProductNameSort; new_data.Color = data.Color ?? ""; new_data.Status = 1; new_data.CreateBy = data.CreateBy ?? 0; new_data.CreateDate = DateTime.Now; new_data.UpdateBy = data.UpdateBy ?? 0; new_data.UpdateDate = DateTime.Now; new_data.Note = data.Note ?? ""; _context.Entry(new_data).State = EntityState.Added; _context.SaveChanges(); var product_price = new PRODUCT_PRICE(); product_price.ProductID = new_data.ProductID; product_price.CurrentPrice = data.CurrentPrice; product_price.CreateBy = data.CreateBy ?? 0; product_price.CreateDate = DateTime.Now; product_price.UpdateBy = data.UpdateBy ?? 0; product_price.UpdateDate = DateTime.Now; product_price.Note = data.Note ?? ""; var result = CreatedProductPrice(product_price); return result; } else { var checkdata = _context.PRODUCTs.Where(x => x.ProductNameDesc == data.ProductNameDesc && x.ProductID != data.ProductID).ToList(); if (checkdata.Count() > 0) { return -1; } var old_data = _context.PRODUCTs.Find(data.ProductID); if (old_data != null) { old_data.ProductNameDesc = data.ProductNameDesc; old_data.ProductNameSort = data.ProductNameSort; old_data.Color = data.Color ?? ""; old_data.Status = 1; old_data.UpdateBy = data.UpdateBy ?? 0; old_data.UpdateDate = DateTime.Now; old_data.Note = data.Note ?? ""; _context.Entry(old_data).State = EntityState.Modified; _context.SaveChanges(); var product_price = new PRODUCT_PRICE(); product_price.ProductID = data.ProductID; product_price.CurrentPrice = data.CurrentPrice; product_price.CreateBy = data.CreateBy ?? 0; product_price.CreateDate = DateTime.Now; product_price.UpdateBy = data.UpdateBy ?? 0; product_price.UpdateDate = DateTime.Now; product_price.Note = data.Note ?? ""; var result = CreatedProductPrice(product_price); return result; } return 0; } } catch (Exception ex) { return 0; } }
public int Delete(ProductionModel data) { var checkdata = _context.PRODUCTs.Find(data.ProductID); if (checkdata != null) { checkdata.Status = 0; checkdata.UpdateBy = data.UpdateBy ?? 0; checkdata.UpdateDate = DateTime.Now; _context.Entry(checkdata).State = EntityState.Modified; _context.SaveChanges(); return 1; } else { return 0; } }