Esempio n. 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dgvProduct.SelectedRows.Count <= 0)
            {
                return;
            }

            DialogResult dr = MessageBox.Show("Are you sure ?", "Confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dr != DialogResult.Yes)
            {
                return;
            }

            DAL.Product pr = new DAL.Product();
            pr.Id = Convert.ToInt32(dgvProduct.SelectedRows[0].Cells["colId"].Value);
            if (pr.delete())
            {
                MessageBox.Show("Deleted");
                btnSearch.PerformClick();
            }
            else
            {
                MessageBox.Show(pr.Error);
            }
        }
        private void frmPurchaseNew_Load(object sender, EventArgs e)
        {
            //loading ComboBox
            DAL.Ledger   ld = new DAL.Ledger();
            DAL.Employee em = new DAL.Employee();
            DAL.Product  p  = new DAL.Product();
            DAL.Purchase pr = new DAL.Purchase();

            cmbLedger.DataSource    = ld.select().Tables[0];
            cmbLedger.DisplayMember = "name";
            cmbLedger.ValueMember   = "id";
            cmbLedger.SelectedValue = -1;

            cmbEmployee.DataSource    = em.select().Tables[0];
            cmbEmployee.DisplayMember = "name";
            cmbEmployee.ValueMember   = "id";
            cmbEmployee.SelectedValue = -1;

            //product
            colProduct.DataSource    = p.select().Tables[0];
            colProduct.DisplayMember = "name";
            colProduct.ValueMember   = "id";

            this.MaximumSize = this.Size;
            this.MinimumSize = this.Size;
        }
Esempio n. 3
0
        public override void New()
        {
            product = new DAL.Product()
            {
                Code     = GetNewProductCode(),
                IsActive = true
            };
            var db    = new DAL.dbDataContext();
            var categ = db.ProductCategories.Where(x => db.ProductCategories.Where(w => w.ParentID == x.ID).Count() == 0).FirstOrDefault();

            if (categ != null)
            {
                product.CategoryID = categ.ID;
            }

            base.New();

            this.Text = "اضافه صنف جديد";

            var data = gridView1.DataSource as BindingList <DAL.ProductUnit>;

            if (db.UnitNames.Count() == 0)
            {
                db.UnitNames.InsertOnSubmit(new DAL.UnitName()
                {
                    Name = "قطعة"
                });
                db.SubmitChanges();
                RefreshData();
            }
            data.Add(new DAL.ProductUnit()
            {
                factor = 1, UnitID = db.UnitNames.First().ID, Barcode = GetNewBarCode()
            });
        }
        private void SaveBarcode(Guid productId)
        {
            DAL.Product oProduct = DAL.Product.Load(productId);
            if (oProduct != null)
            {
                string stkcode = oProduct.STKCODE;

                if (oProduct.STKCODE.Length > 10)
                {
                    stkcode = oProduct.STKCODE.Remove(10);
                }

                string barcode = stkcode + oProduct.APPENDIX1 + oProduct.APPENDIX2 + oProduct.APPENDIX3;
                string sql     = "ProductId = '" + oProduct.ProductId.ToString() + "' AND Barcode = '" + barcode + "'";

                DAL.ProductBarcode oBarcode = DAL.ProductBarcode.LoadWhere(sql);
                if (oBarcode == null)
                {
                    oBarcode                   = new DAL.ProductBarcode();
                    oBarcode.ProductId         = oProduct.ProductId;
                    oBarcode.Barcode           = barcode;
                    oBarcode.BarcodeType       = "INTER";
                    oBarcode.PrimaryBarcode    = true;
                    oBarcode.DownloadToPOS     = chkRetailItem.Checked;
                    oBarcode.DownloadToCounter = chkCounterItem.Checked;

                    oBarcode.Save();
                }
            }
        }
Esempio n. 5
0
        public bool SaveRec(Guid productId)
        {
            bool result = false;

            DAL.Product oProduct = DAL.Product.Load(productId);
            if (oProduct != null)
            {
                oProduct.FixedPriceItem = chkFixedPrice.Checked;
                oProduct.Save();

                string sql = "ProductId = '" + productId.ToString() + "'";
                DAL.ProductSupplement oProdSupp = DAL.ProductSupplement.LoadWhere(sql);
                if (oProdSupp == null)
                {
                    oProdSupp = new DAL.ProductSupplement();

                    oProdSupp.ProductId = productId;
                }

                oProdSupp.VipDiscount_FixedItem      = Convert.ToDecimal((txtDiscount1_FixPriceItem.Text == string.Empty) ? "0" : txtDiscount1_FixPriceItem.Text);
                oProdSupp.VipDiscount_DiscountItem   = Convert.ToDecimal((txtDiscount2_DiscountItem.Text == string.Empty) ? "0" : txtDiscount2_DiscountItem.Text);
                oProdSupp.VipDiscount_NoDiscountItem = Convert.ToDecimal((txtDiscount3_NoDiscountItem.Text == string.Empty) ? "0" : txtDiscount3_NoDiscountItem.Text);
                oProdSupp.StaffDiscount = Convert.ToDecimal((txtStaff.Text == string.Empty) ? "0" : txtStaff.Text);
                oProdSupp.Save();

                _ProductId = productId;
                result     = true;
            }
            return(result);
        }
Esempio n. 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int er = 0;

            if (txtName.Text == "")
            {
                er++;
                ep.SetError(txtName, "Required");
            }
            //validation baki
            DAL.Product p = new DAL.Product();
            p.BrandId     = Convert.ToInt32(cmbBrand.SelectedValue);
            p.CategoryId  = Convert.ToInt32(cmbCategory.SelectedValue);
            p.Code        = txtCode.Text;
            p.Description = txtDescription.Text;
            p.Discount    = Convert.ToDouble(txtDiscount.Text);
            p.Name        = txtName.Text;
            p.Offers      = txtOffer.Text;
            p.Tag         = txtTag.Text;
            p.Type        = cmbType.Text;
            if (p.Insert())
            {
                MessageBox.Show("Data Saved");
                MyControls.Helper.clear(this);
                txtName.Focus();
            }
            else
            {
                MessageBox.Show(p.Error);
            }
        }
Esempio n. 7
0
 public void Add(Backend.Product p)
 {
     DB.Add(p);
     DAL.Product temp = Change.ProductBackendToDal(p);
     emartDataContext.Products.InsertOnSubmit(temp);
     emartDataContext.SubmitChanges();
 }
        public void AddOperation(DateTime date, Manager manager, string clientName, string productName, Session session, int price)
        {
            DAL.Client  client  = _salesContext.Clients.FirstOrDefault(x => x.Name == clientName);
            DAL.Product product = _salesContext.Products.FirstOrDefault(x => x.Name == productName);

            if (client == null)
            {
                client = new DAL.Client()
                {
                    Name = clientName
                }
            }
            ;
            if (product == null)
            {
                product = new DAL.Product()
                {
                    Name = productName
                }
            }
            ;

            DAL.Operation operation = new DAL.Operation()
            {
                DateOfOperation = date,
                Manager         = ToEntity(manager),
                Client          = client,
                Product         = product,
                Session         = ToEntity(session),
                Price           = price
            };

            _salesContext.Operations.Add(operation);
            _salesContext.SaveChanges();
        }
Esempio n. 9
0
        private bool Save()
        {
            bool result = false;

            if (Verify())
            {
                Cursor.Current = Cursors.WaitCursor;
                #region 2013.12.22 paulus: 舊 code,唔再用
                //this.ProductId = SaveGeneralInfo();
                //if (this.ProductId != System.Guid.Empty)
                //{
                //    SaveProductCurrentSummary(this.ProductId);

                //    SaveQtyInfo();
                //    SaveOrderInfo();
                //    SaveDiscountInfo();

                //    result = true;
                //}
                #endregion
                if (_ProductId == Guid.Empty)
                {
                    SaveAsNewProduct();
                }
                else
                {
                    DAL.Product oProduct = DAL.Product.Load(_ProductId);
                    oProduct.Status     = Convert.ToInt32(RT2020.DAL.Common.Enums.Status.Modified.ToString("d"));
                    oProduct.ModifiedBy = RT2020.DAL.Common.Config.CurrentUserId;
                    oProduct.ModifiedOn = DateTime.Now;
                    oProduct.Save();
                }
                if (_ProductId != Guid.Empty)
                {
                    general.SaveRec(_ProductId);

                    if (tpQty.Contains(quantity))
                    {
                        quantity.SaveRec(_ProductId);
                    }
                    if (tpMisc.Contains(misc))
                    {
                        misc.SaveRec(_ProductId);
                    }
                    if (tpOrder.Contains(order))
                    {
                        order.SaveRec(_ProductId);
                    }
                    if (tpDiscount.Contains(discount))
                    {
                        discount.SaveRec(_ProductId);
                    }
                    result = true;
                }
                Cursor.Current = Cursors.Default;
            }

            return(result);
        }
 private void frmProductPriceNew_Load(object sender, EventArgs e)
 {
     DAL.Product p = new DAL.Product();
     DAL.Unit    u = new DAL.Unit();
     cmbProduct.Source(p.Select());
     cmbUnit.Source(u.Select());
     MyControls.Helper.Numeric(txtPrice);
 }
Esempio n. 11
0
 private void frmProductImage_Load(object sender, EventArgs e)
 {
     DAL.Product p = new DAL.Product();
     cmbProduct.DataSource    = p.select().Tables[0];
     cmbProduct.DisplayMember = "name";
     cmbProduct.ValueMember   = "id";
     cmbProduct.SelectedValue = -1;
 }
        private void frmProductImageNew_Load(object sender, EventArgs e)
        {
            DAL.Product p = new DAL.Product();
            cmbProduct.Source(p.Select());

            this.MinimumSize = Size;
            this.MaximumSize = Size;
        }
Esempio n. 13
0
        private void frmFormulaNew_Load(object sender, EventArgs e)
        {
            DAL.Product p = new DAL.Product();
            cmbProduct.Source(p.Select());

            colProduct.DataSource    = p.Select().Tables[0];
            colProduct.DisplayMember = "name";
            colProduct.ValueMember   = "id";
        }
Esempio n. 14
0
        public void DeleteProduct(int id)
        {
            DAL.Product p = db.Products.Where(x => x.Id == id).FirstOrDefault();

            if (p != null)
            {
                p.IsDeleted = true;
                db.SubmitChanges();
            }
        }
        public void Setup()
        {
            DAL.Product product = new DAL.Product {
                ProductID = 1, ProductNumber = "123", Name = "Jojo", ListPrice = 2, ModifiedDate = DateTime.Now, Weight = 3, DaysToManufacture = 3, WeightUnitMeasureCode = "test code", ProductLine = "line test", Color = "blue", ProductModelID = 2, Class = "first", SellStartDate = DateTime.Now, SellEndDate = DateTime.Now, StandardCost = 2, FinishedGoodsFlag = false, MakeFlag = true, ProductModel = new DAL.ProductModel(), ReorderPoint = 1, rowguid = new Guid(), SafetyStockLevel = 1, Size = "Big", SizeUnitMeasureCode = "123", Style = "style"
            };
            listProducts.Add(product);

            Mapper.CreateMap <Product, ProductVM>();
            Mapper.CreateMap <ProductDescription, ProductDescriptionVM>();
        }
Esempio n. 16
0
 private void ShowRec()
 {
     DAL.Product oProduct = DAL.Product.Load(_ProductId);
     if (oProduct != null)
     {
         txtVendorItemNum.Text   = oProduct.AlternateItem; // Vendor Item Number
         txtReorderLevel.Text    = oProduct.ReorderLevel.ToString("n0");
         txtReorderQuantity.Text = oProduct.ReorderQty.ToString("n0");
     }
 }
Esempio n. 17
0
        void LoadProduct(int id)
        {
            using (var db = new DAL.dbDataContext())
            {
                product = db.Products.Single(x => x.ID == id);
            }
            this.Text = string.Format("بيانات صنف : {0}", product.Name);

            GetData();
        }
 private DAL.Product ToEntity(Product product)
 {
     DAL.Product productDAL = _salesContext.Products.FirstOrDefault(x => x.Name == product.Name);
     if (productDAL != null)
     {
         return(productDAL);
     }
     else
     {
         return(DataMapper.Mapping(product));
     }
 }
Esempio n. 19
0
 public void Save(Product pt)
 {
     DAL.Product pd = new DAL.Product();
     pd.BuyoutPrice     = pt.BuyoutPrice;
     pd.ProductDesigner = pt.ProductDesigner;
     pd.Provision       = pt.Provision;
     pd.StartPrice      = pt.StartPrice;
     pd.SupplierId      = pt.SupplierId;
     pd.TypeId          = (int)pt.Type;
     db.Products.InsertOnSubmit(pd);
     db.SubmitChanges();
 }
        public ValidationResult_OSC PostInsertProduct([FromBody]OnlineShoppingCart.Model.Product product)
        {
            var result = new ValidationResult_OSC();
            ValidationHelper validationHelper = new ValidationHelper(ref result, ModelState);

            if (result.Success)
            {
                DAL.Product productDAL = new DAL.Product();
                result = productDAL.AddProduct(product);
            }
            return result;
        }
Esempio n. 21
0
        private void ShowQtyInfo()
        {
            DAL.Product oProduct = DAL.Product.Load(_ProductId);
            if (oProduct != null)
            {
                txtMaxOLNQty.Text = oProduct.MaxOnLoanQty.ToString("n0");
            }

            txtMTDPurQty.Text  = PurQty("'CAP', 'REC', 'REJ'", "M").ToString("n0");
            txtYTDPurQty.Text  = PurQty("'CAP', 'REC', 'REJ'", "Y").ToString("n0");
            txtMTDSoldQty.Text = SoldQty("'CAS', 'CRT', 'VOD'", "M").ToString("n0");
            txtYTDSoldQty.Text = SoldQty("'CAS', 'CRT', 'VOD'", "Y").ToString("n0");
        }
Esempio n. 22
0
        public static DAL.Product ProductBackendToDal(Backend.Product d)
        {
            DAL.Product temp = new DAL.Product();

            temp.departmentID = d.departmentID;
            temp.inStock      = d.inStock;
            temp.inventoryID  = d.inventoryID;
            temp.isBestSeller = d.isBestSeller;
            temp.name         = d.name;
            temp.price        = d.price;
            temp.stockCount   = d.stockCount;
            temp.type         = d.type.ToString();
            return(temp);
        }
        private void frmFormulaNew_Load(object sender, EventArgs e)
        {
            DAL.Product p = new DAL.Product();
            cmbProduct.Source(p.Select());


            colProduct.DataSource    = p.Select().Tables[0];
            colProduct.DisplayMember = "name";
            colProduct.ValueMember   = "id";

            this.MinimumSize = Size;
            this.MaximumSize = Size;

            MyContorls.Hylper.Numeric(txtQty);
        }
Esempio n. 24
0
        public void UpdateProduct(Product pt)
        {
            DAL.Product pd = db.Products.Where(x => x.Id == pt.Id).FirstOrDefault();

            if (pd != null)
            {
                pd.Id              = pt.Id;
                pd.BuyoutPrice     = pt.BuyoutPrice;
                pd.ProductDesigner = pt.ProductDesigner;
                pd.Provision       = pt.Provision;
                pd.StartPrice      = pt.StartPrice;
                pd.SupplierId      = pt.SupplierId;
                pd.TypeId          = (int)pt.Type;
                db.SubmitChanges();
            }
        }
 public ActionResult Delete(int Id)
 {
     try
     {
         using (var context = new DAL.KalyaniProdDbEntities())
         {
             DAL.Product product = context.Products.Find(Id);
             context.Products.Remove(product);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 26
0
        public bool SaveRec(Guid productId)
        {
            bool result = false;

            DAL.Product oProduct = DAL.Product.Load(productId);
            if (oProduct != null)
            {
                SaveProduct(productId);
                SaveProductCode(productId);
                SaveBarcode(productId);
                SaveSupplement(oProduct.ProductId);
                SavePrices(oProduct.ProductId);
                SaveRemarks(oProduct.ProductId);
                SaveCurrentSummary(oProduct.ProductId);
            }

            return(result);
        }
Esempio n. 27
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DAL.Product product = new DAL.Product();
            product.Search = txtSearch.Text;
            try
            {
                product.BrandId    = Convert.ToInt32(cmbBrand.SelectedValue);
                product.CategoryId = Convert.ToInt32(cmbCategory.SelectedValue);
            }
            catch { }

            //DateSearch
            product.isDateSearch = ucDateSearch1.isEnabled;
            product.DateFrom     = ucDateSearch1.DateFrom;
            product.DateTo       = ucDateSearch1.DateTo;

            dgvProduct.DataSource = product.select().Tables[0];
        }
Esempio n. 28
0
        private void ShowRec()
        {
            DAL.Product oProduct = DAL.Product.Load(_ProductId);
            if (oProduct != null)
            {
                chkFixedPrice.Checked = oProduct.FixedPriceItem;
            }

            string sql = "ProductId = '" + _ProductId.ToString() + "'";

            DAL.ProductSupplement oProdSupp = DAL.ProductSupplement.LoadWhere(sql);
            if (oProdSupp != null)
            {
                this.txtDiscount1_FixPriceItem.Text   = oProdSupp.VipDiscount_FixedItem.ToString("n2");
                this.txtDiscount2_DiscountItem.Text   = oProdSupp.VipDiscount_DiscountItem.ToString("n2");
                this.txtDiscount3_NoDiscountItem.Text = oProdSupp.VipDiscount_NoDiscountItem.ToString("n2");
                this.txtStaff.Text = oProdSupp.StaffDiscount.ToString("n2");
            }
        }
        private void FindAndShow()
        {
            String stkcode = txtStockCode.Text.Trim();

            if (stkcode != String.Empty)
            {
                Cursor.Current = Cursors.WaitCursor;
                String      sql      = String.Format("STKCODE = '{0}'", stkcode);
                DAL.Product oProduct = DAL.Product.LoadWhere(sql);
                if (oProduct != null)
                {
                    this.ProductId = oProduct.ProductId;
                    ShowRecords();
                }
                else
                {
                    MessageBox.Show(String.Format("No such product...{0}!", txtStockCode.Text.Trim()));
                }
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 30
0
 private void GetDataFromList(ref DataTable table)
 {
     foreach (Inventory.GoodsReceive.DetailData detailData in _Result)
     {
         DAL.Product product = DAL.Product.Load(detailData.ProductId);
         if (product != null)
         {
             DataRow[] rows = table.Select(string.Format("ProductId = '{0}'", product.ProductId.ToString()));
             if (rows.Length > 0)
             {
                 for (int i = 0; i < rows.Length; i++)
                 {
                     DataRow row = rows[i];
                     row["OrderedQty"] = detailData.Qty;
                     row["UnitCost"]   = detailData.UnitAmount > 0 ? detailData.UnitAmount : Convert.ToDecimal(product.RetailPrice.ToString("n2"));
                     row["Status"]     = "EDIT";
                     row.EndEdit();
                     row.AcceptChanges();
                 }
             }
             else
             {
                 DataRow row = table.NewRow();
                 row["DetailsId"]   = Guid.Empty;
                 row["LineNumber"]  = table.Rows.Count + 1;
                 row["STKCODE"]     = product.STKCODE;
                 row["APPENDIX1"]   = product.APPENDIX1;
                 row["APPENDIX2"]   = product.APPENDIX2;
                 row["APPENDIX3"]   = product.APPENDIX3;
                 row["ProductName"] = product.ProductName;
                 row["OrderedQty"]  = detailData.Qty;
                 row["UnitCost"]    = detailData.UnitAmount > 0 ? detailData.UnitAmount : Convert.ToDecimal(product.RetailPrice.ToString("n2"));
                 row["ProductId"]   = product.ProductId;
                 row["Status"]      = "NEW";
                 table.Rows.Add(row);
             }
         }
     }
 }
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            // MessageBox.Show(e.RowIndex.ToString() + "," + e.ColumnIndex.ToString());

            if (e.ColumnIndex == 0 && e.RowIndex >= 0)
            {
                DAL.Product p = new DAL.Product();
                p.Id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["colProduct"].Value);
                p.selectById();
                dataGridView1.Rows[e.RowIndex].Cells["colQty"].Value      = 1;
                dataGridView1.Rows[e.RowIndex].Cells["colRate"].Value     = p.Price;
                dataGridView1.Rows[e.RowIndex].Cells["colSubTotal"].Value = 1 * p.Price;
            }

            if ((e.ColumnIndex == 1 || e.ColumnIndex == 2) && e.RowIndex >= 0)
            {
                double qty  = Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells["colQty"].Value);
                double rate = Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells["colRate"].Value);
                dataGridView1.Rows[e.RowIndex].Cells["colSubTotal"].Value = qty * rate;
            }
            loadTotal();
        }
Esempio n. 32
0
 public void Save(Product pt)
 {
     DAL.Product pd = new DAL.Product();
     pd.BuyoutPrice = pt.BuyoutPrice;
     pd.ProductDesigner = pt.ProductDesigner;
     pd.Provision = pt.Provision;
     pd.StartPrice = pt.StartPrice;
     pd.SupplierId = pt.SupplierId;
     pd.TypeId = (int)pt.Type;
     db.Products.InsertOnSubmit(pd);
     db.SubmitChanges();
 }
 public Result<OnlineShoppingCart.Model.Product> GetProduct(int id)
 {
     DAL.Product product = new DAL.Product();
     return product.GetProduct(id);
 }
 public Result<List<OnlineShoppingCart.Model.Product>> Get([FromUri]OnlineShoppingCart.Model.Product product)
 {
     DAL.Product productDAL = new DAL.Product();
     return productDAL.GetProductList(product);
 }
 // DELETE api/values/5
 public ValidationResult_OSC Delete(int id)
 {
     DAL.Product productDAL = new DAL.Product();
     return productDAL.DeletProduct(id);
 }