Beispiel #1
0
        private void btnEditItem_Click(object sender, EventArgs e)
        {
            if (lvDetailsList.SelectedItem != null)
            {
                if (basicProduct.SelectedItem != null)
                {
                    var oProd = ProductEx.Get(this.ProductId);
                    if (oProd != null)
                    {
                        ListViewItem listItem = lvDetailsList.SelectedItem;
                        listItem.SubItems[2].Text = listItem.SubItems[2].Text != "NEW" ? "EDIT" : listItem.SubItems[2].Text; // Status
                        listItem.SubItems[3].Text = oProd.STKCODE;                                                           // Stock Code
                        listItem.SubItems[4].Text = oProd.APPENDIX1;                                                         // Appendix1
                        listItem.SubItems[5].Text = oProd.APPENDIX2;                                                         // Appendix2
                        listItem.SubItems[6].Text = oProd.APPENDIX3;                                                         // Appendix3
                        listItem.SubItems[7].Text = txtDescription.Text;                                                     // Description
                        listItem.SubItems[8].Text = txtQty.Text;                                                             // Qty
                        listItem.SubItems[9].Text = txtUnitAmount.Text;                                                      // Unit Amount

                        decimal qty   = Convert.ToDecimal(txtQty.Text.Length == 0 ? "0" : txtQty.Text);
                        decimal price = Convert.ToDecimal(txtUnitAmount.Text.Length == 0 ? "0" : txtUnitAmount.Text);
                        decimal amt   = qty * price;
                        listItem.SubItems[10].Text = amt.ToString("n2");        // Amount
                        listItem.SubItems[11].Text = this.ProductId.ToString(); // ProductId

                        CalcTotal();

                        basicProduct.ResultList = SetDetailData(oProd.STKCODE);
                    }
                }
            }
        }
Beispiel #2
0
        private void cboFullStockCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            string query     = string.Empty;
            Guid   productId = Guid.Empty;

            //* 搞咩呢?cboFullStockCode 一定係 ProductId + stkcode
            if (cboFullStockCode.SelectedValue != null && Guid.TryParse(cboFullStockCode.SelectedValue.ToString(), out productId))
            {
                query = "ProductId = '" + productId.ToString() + "'";
            }
            else
            {
                query = BuildWhereClause(cboFullStockCode.Text.Trim());
            }

            if (query.Length > 0)
            {
                var oProd = ProductEx.Get(query);
                if (oProd != null)
                {
                    this.SelectedItem = oProd.ProductId;

                    ProductSelectionEventArgs args = new ProductSelectionEventArgs(oProd.ProductId, oProd.STKCODE, oProd.APPENDIX1, oProd.APPENDIX2,
                                                                                   oProd.APPENDIX3,
                                                                                   oProd.ProductName,
                                                                                   oProd.RetailPrice.Value,
                                                                                   Utility.GetOnHandQtyByCurrentZone(oProd.ProductId),
                                                                                   oProd.OriginalRetailPrice.Value,
                                                                                   ProductCurrentSummaryEx.GetAverageCode(oProd.ProductId),
                                                                                   oProd.NormalDiscount);

                    OnSelectionChanged(args);
                }
            }
        }
Beispiel #3
0
        private void ItemInfo(ref string stkCode, ref string appendix1, ref string appendix2, ref string appendix3)
        {
            if (basicProduct.SelectedItem != null)
            {
                string query = string.Empty;
                if (basicProduct.SelectedItem != null)
                {
                    query = "ProductId = '" + basicProduct.SelectedItem.ToString() + "'";
                }
                else if (basicProduct.cboFullStockCode.Text.Trim().Length > 0)
                {
                    query = BuildWhereClause(basicProduct.cboFullStockCode.Text.Trim());
                }

                if (query.Length > 0)
                {
                    var oProd = ProductEx.Get(query);
                    if (oProd != null)
                    {
                        stkCode   = oProd.STKCODE;
                        appendix1 = oProd.APPENDIX1;
                        appendix2 = oProd.APPENDIX2;
                        appendix3 = oProd.APPENDIX3;

                        this.ProductId = oProd.ProductId;
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public ProductEx GetEx(int productId)
        {
            ProductEx data = null;

            using (SqlConnection cn = GetConnection())
            {
                SqlCommand cmd = cn.CreateCommand();
                cmd.CommandText = @"  SELECT *
                           FROM Products as p
                          left join ProductAttributes as pa on p.ProductID = pa.ProductID
                          left join ProductGallery as pg on p.ProductID = pg.ProductID 
                            WHERE  p.ProductID = @ProductID";
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@ProductID", productId);
                using (SqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (dbReader.Read())
                    {
                        data = new ProductEx()
                        {
                            ProductID   = Convert.ToInt32(dbReader["ProductID"]),
                            ProductName = Convert.ToString(dbReader["ProductName"]),
                            SupplierID  = Convert.ToInt32(dbReader["SupplierID"]),
                            CategoryID  = Convert.ToInt32(dbReader["CategoryID"]),
                            Unit        = Convert.ToString(dbReader["Unit"]),
                            Price       = Convert.ToDecimal(dbReader["Price"]),
                            Photo       = Convert.ToString(dbReader["Photo"])
                        };
                    }
                }
                cn.Close();
            }
            return(data);
        }
Beispiel #5
0
        public ProductEx GetEx(int productID)
        {
            Product product = Get(productID);

            if (product == null)
            {
                return(null);
            }
            List <ProductAttribute> listAttributes = this.ListAttributes(productID);
            List <ProductGallery>   listGallery    = this.ListGallery(productID);
            ProductEx data = new ProductEx()
            {
                ProductID   = product.ProductID,
                CategoryID  = product.CategoryID,
                Photo       = product.Photo,
                Price       = product.Price,
                ProductName = product.ProductName,
                SupplierID  = product.SupplierID,
                Unit        = product.Unit,
                Attributes  = listAttributes,
                Galleries   = listGallery
            };

            return(data);
        }
Beispiel #6
0
        public ActionResult Update(Product product)
        {
            ProductEx productEx = new ProductEx();

            productEx.Update(product);
            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        public ActionResult Insert(Product product)
        {
            ProductEx productEx = new ProductEx();

            productEx.Insert(product);
            return(RedirectToAction("Index"));
        }
Beispiel #8
0
        public ActionResult Details(int id)
        {
            ProductEx productEx = new ProductEx();
            var       product   = productEx.GetById(id);

            return(View(product));
        }
Beispiel #9
0
        public ActionResult Delete(int id)
        {
            ProductEx productEx = new ProductEx();

            productEx.Delete(id);
            return(RedirectToAction("Index"));
        }
Beispiel #10
0
        private void AssertEqual(ProductEx p1, PhoneCase p2, double rate = 1)
        {
            Assert.AreEqual(p1.Id, p2.Id);
            Assert.AreEqual(p1.Name, p2.Name);
            Assert.AreEqual(p1.Price, p2.Price * rate);

            Assert.AreEqual(p1.Type, "Phone Case");
        }
Beispiel #11
0
        private void AssertEqual(ProductEx p1, Lawnmower p2, double rate = 1)
        {
            Assert.AreEqual(p1.Id, p2.Id);
            Assert.AreEqual(p1.Name, p2.Name);
            Assert.AreEqual(p1.Price, p2.Price * rate);

            Assert.AreEqual(p1.Type, "Lawnmower");
        }
Beispiel #12
0
        private void AssertEqual(ProductEx p1, TShirt p2, double rate = 1)
        {
            Assert.AreEqual(p1.Id, p2.Id);
            Assert.AreEqual(p1.Name, p2.Name);
            Assert.AreEqual(p1.Price, p2.Price * rate);

            Assert.AreEqual(p1.Type, "T-Shirt");
        }
Beispiel #13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public JsonResult Save(ProductEx model)
        {
            model.CreateDate = DateTime.Now;
            model.StaffID    = UserInfo.Id;
            model.StaffName  = UserInfo.UserName;

            var json = _proBll.Edit(model);

            return(Json(json));
        }
Beispiel #14
0
        public ApiMessage <string> Edit(ProductEx t)
        {
            using (var scope = new PetaPoco.Transaction(_db))
            {
                try
                {
                    if (string.IsNullOrEmpty(t.ID))
                    {
                        t.ID   = Guid.NewGuid().ToString();
                        t.Code = CodeNo.Get(CodeType.Product);
                        t.Insert();

                        for (int i = 0; i < t.Imgs.Count; i++)
                        {
                            var item = t.Imgs[i];
                            var img  = new productimg
                            {
                                ID        = Guid.NewGuid().ToString(),
                                ProductID = t.ID,
                                RowNO     = i,
                                Url       = item.url
                            };
                            img.Insert();
                        }
                    }
                    else
                    {
                        t.Update();
                        productimg.Delete("where ProductId=@0", t.ID);
                        for (int i = 0; i < t.Imgs.Count; i++)
                        {
                            var item = t.Imgs[i];
                            var img  = new productimg
                            {
                                ID        = Guid.NewGuid().ToString(),
                                ProductID = t.ID,
                                RowNO     = i,
                                Url       = item.url
                            };
                            img.Insert();
                        }
                    }
                    scope.Complete();
                    return(new ApiMessage <string>());
                }
                catch (Exception e)
                {
                    scope.Dispose();
                    throw e;
                }
            }
        }
Beispiel #15
0
 private void LoadProductList()
 {
     /**
      * string where = string.Format("STKCODE = '{0}'", txtStockCode.Text.Trim());
      * DAL.Product oProd = DAL.Product.LoadWhere(where);
      * if (oProd != null)
      * {
      *  this.txtProductName.Text = oProd.ProductName;
      * }
      */
     this.txtProductName.Text = ProductEx.GetProductNameBySTKCODE(txtStockCode.Text.Trim());
     BindData();
 }
Beispiel #16
0
        private Guid GetProductId(TxferTxtIEDetails detail)
        {
            string sql   = "STKCODE = '" + detail.StockCode + "' AND APPENDIX1 = '" + detail.Appendix1 + "' AND APPENDIX2 = '" + detail.Appendix2 + "' AND APPENDIX3 = '" + detail.Appendix3 + "'";
            var    oItem = ProductEx.Get(sql);

            if (oItem != null)
            {
                return(oItem.ProductId);
            }
            else
            {
                return(System.Guid.Empty);
            }
        }
        private Guid GetProductId(string stkCode, string appendix1, string appendix2, string appendix3)
        {
            string sql      = "STKCODE = '" + stkCode + "' AND APPENDIX1 = '" + appendix1 + "' AND APPENDIX2 = '" + appendix2 + "' AND APPENDIX3 = '" + appendix3 + "'";
            var    oProduct = ProductEx.Get(sql);

            if (oProduct != null)
            {
                return(oProduct.ProductId);
            }
            else
            {
                return(System.Guid.Empty);
            }
        }
Beispiel #18
0
        public void AddItemByList(List <RT2020.Controls.ProductSearcher.DetailData> resultList)
        {
            foreach (RT2020.Controls.ProductSearcher.DetailData detail in resultList)
            {
                var oProduct = ProductEx.Get(detail.ProductId);
                if (oProduct != null)
                {
                    string stkCode   = oProduct.STKCODE;
                    string appendix1 = oProduct.APPENDIX1;
                    string appendix2 = oProduct.APPENDIX2;
                    string appendix3 = oProduct.APPENDIX3;

                    decimal amt = detail.Qty * detail.UnitAmount;

                    if (IsDuplicated(stkCode, appendix1, appendix2, appendix3))
                    {
                        foreach (ListViewItem lvItem in lvDetailsList.Items)
                        {
                            if (lvItem.SubItems[11].Text == oProduct.ProductId.ToString() && lvItem.SubItems[2].Text != "REMOVED")
                            {
                                if (lvItem.SubItems[8].Text != detail.Qty.ToString("n0") || lvItem.SubItems[9].Text != detail.UnitAmount.ToString("n2"))
                                {
                                    lvItem.SubItems[2].Text  = lvItem.SubItems[2].Text != "NEW" ? "EDIT" : lvItem.SubItems[2].Text; // Status
                                    lvItem.SubItems[8].Text  = detail.Qty.ToString("n0");                                           // QTY
                                    lvItem.SubItems[9].Text  = detail.UnitAmount.ToString("n2");                                    // Unit Amount
                                    lvItem.SubItems[10].Text = amt.ToString("n2");                                                  // Amount
                                }
                            }
                        }
                    }
                    else
                    {
                        ListViewItem listItem = lvDetailsList.Items.Add(System.Guid.Empty.ToString());
                        listItem.SubItems.Add(lvDetailsList.Items.Count.ToString());
                        listItem.SubItems.Add("NEW");                            // Status
                        listItem.SubItems.Add(stkCode);                          // Stock Code
                        listItem.SubItems.Add(appendix1);                        // Appendix1
                        listItem.SubItems.Add(appendix2);                        // Appendix2
                        listItem.SubItems.Add(appendix3);                        // Appendix3
                        listItem.SubItems.Add(oProduct.ProductName);             // Description
                        listItem.SubItems.Add(detail.Qty.ToString("n0"));        // Qty
                        listItem.SubItems.Add(detail.UnitAmount.ToString("n2")); // Unit Amount
                        listItem.SubItems.Add(amt.ToString("n2"));               // Amount
                        listItem.SubItems.Add(oProduct.ProductId.ToString());    // ProductId
                    }
                }
            }

            CalcTotal();
        }
Beispiel #19
0
        private void ItemInfo(ref string stkCode, ref string appendix1, ref string appendix2, ref string appendix3)
        {
            if (basicProduct.SelectedItem != null)
            {
                var oProd = ProductEx.Get((Guid)basicProduct.SelectedItem);
                if (oProd != null)
                {
                    stkCode   = oProd.STKCODE;
                    appendix1 = oProd.APPENDIX1;
                    appendix2 = oProd.APPENDIX2;
                    appendix3 = oProd.APPENDIX3;

                    this.ProductId = oProd.ProductId;
                }
            }
        }
Beispiel #20
0
        private void ItemInfo(ref string stkCode, ref string appendix1, ref string appendix2, ref string appendix3)
        {
            if (basicProduct.SelectedItem != null)
            {
                //RT2020.DAL.Product oProd = RT2020.DAL.Product.Load(new Guid(basicProduct.SelectedItem.ToString()));
                var oProd = ProductEx.Get((Guid)basicProduct.SelectedItem);
                if (oProd != null)
                {
                    stkCode   = oProd.STKCODE;
                    appendix1 = oProd.APPENDIX1;
                    appendix2 = oProd.APPENDIX2;
                    appendix3 = oProd.APPENDIX3;

                    _ProductId = oProd.ProductId;
                }
            }
        }
Beispiel #21
0
        private void GenBarcode()
        {
            StringBuilder barcode = new StringBuilder();
            var           oItem   = ProductEx.Get(this.ProductId);

            if (oItem != null)
            {
                barcode.Append(oItem.STKCODE);
                barcode.Append(oItem.APPENDIX1);
                barcode.Append(oItem.APPENDIX2);
                barcode.Append(oItem.APPENDIX3);
            }

            txtBarcode.Text = barcode.ToString();
            cboBarcodeType.SelectedIndex = 0;
            chkPrimaryBarcode.CheckState = Gizmox.WebGUI.Forms.CheckState.Checked;
        }
Beispiel #22
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            if (basicProduct.SelectedItem != null)
            {
                var oProd = ProductEx.Get((Guid)basicProduct.SelectedItem);
                if (oProd != null)
                {
                    if (IsDuplicated(oProd.STKCODE, oProd.APPENDIX1, oProd.APPENDIX2, oProd.APPENDIX3))
                    {
                        //this.Invoke(new EventHandler(btnEditItem_Click), new object[] { this, e });
                        MessageBox.Show(string.Format(Resources.Common.DuplicatedCode, "Stock Item"), string.Format(Resources.Common.DuplicatedCode, string.Empty));
                    }
                    else
                    {
                        if (this.ProductId != System.Guid.Empty)
                        {
                            ListViewItem listItem = lvDetailsList.Items.Add(System.Guid.Empty.ToString());
                            listItem.SubItems.Add(lvDetailsList.Items.Count.ToString());
                            listItem.SubItems.Add("NEW");                                       // Status
                            listItem.SubItems.Add(oProd.STKCODE);                               // Stock Code
                            listItem.SubItems.Add(oProd.APPENDIX1);                             // Appendix1
                            listItem.SubItems.Add(oProd.APPENDIX2);                             // Appendix2
                            listItem.SubItems.Add(oProd.APPENDIX3);                             // Appendix3
                            listItem.SubItems.Add(txtDescription.Text);                         // Description
                            listItem.SubItems.Add(txtQty.Text.Length == 0 ? "0" : txtQty.Text); // Rej. Qty
                            listItem.SubItems.Add(txtUnitAmount.Text);                          // Unit Amount

                            decimal qty       = Convert.ToDecimal(txtQty.Text.Length == 0 ? "0" : txtQty.Text);
                            decimal unitPrice = Convert.ToDecimal(txtUnitAmount.Text.Length == 0 ? "0" : txtUnitAmount.Text);
                            decimal amt       = qty * unitPrice;
                            listItem.SubItems.Add(amt.ToString("n2"));        // Amount
                            listItem.SubItems.Add(this.ProductId.ToString()); // ProductId

                            CalcTotal();
                        }
                    }
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// Gets the price.
        /// </summary>
        /// <param name="productId">The product id.</param>
        /// <returns></returns>
        private decimal GetPrice(Guid productId)
        {
            decimal result = 0;

            switch (this.TxType)
            {
            case EnumHelper.TxType.ADJ:
                result = ProductCurrentSummaryEx.GetAverageCode(productId);
                break;

            case EnumHelper.TxType.TXF:
                //DAL.Product product = DAL.Product.Load(productId);
                //if (product != null)
                //{
                //    result = product.RetailPrice;
                //}
                result = ProductEx.GetRetailPrice(productId);
                break;
            }

            return(result);
        }
        private string[] GetProductCode(Guid productId)
        {
            List <string> productCode = new List <string>();

            var product = ProductEx.Get(productId);

            if (product != null)
            {
                productCode.Add(product.STKCODE);
                productCode.Add(product.APPENDIX1);
                productCode.Add(product.APPENDIX2);
                productCode.Add(product.APPENDIX3);
            }
            else
            {
                productCode.Add(string.Empty);
                productCode.Add(string.Empty);
                productCode.Add(string.Empty);
                productCode.Add(string.Empty);
            }

            return(productCode.ToArray());
        }
Beispiel #25
0
        private void LoadIntoDetailList(XlsImportTemplate[] res)
        {
            int  iCount    = 0;
            Guid productId = System.Guid.Empty;

            lvDetailsList.Items.Clear();
            btnImport.Enabled = false;

            if (res.Length > 0)
            {
                foreach (XlsImportTemplate row in res)
                {
                    iCount++;
                    if (row.STOCKCODE == null)
                    {
                        row.STOCKCODE = System.String.Empty;
                    }
                    if (row.APPENDIX1 == null)
                    {
                        row.APPENDIX1 = System.String.Empty;
                    }
                    if (row.APPENDIX2 == null)
                    {
                        row.APPENDIX2 = System.String.Empty;
                    }
                    if (row.APPENDIX3 == null)
                    {
                        row.APPENDIX3 = System.String.Empty;
                    }
                    if (row.CLASS1 == null)
                    {
                        row.CLASS1 = System.String.Empty;
                    }
                    if (row.CLASS2 == null)
                    {
                        row.CLASS2 = System.String.Empty;
                    }
                    if (row.CLASS3 == null)
                    {
                        row.CLASS3 = System.String.Empty;
                    }
                    if (row.CLASS4 == null)
                    {
                        row.CLASS4 = System.String.Empty;
                    }
                    if (row.CLASS5 == null)
                    {
                        row.CLASS5 = System.String.Empty;
                    }
                    if (row.CLASS6 == null)
                    {
                        row.CLASS6 = System.String.Empty;
                    }
                    if (row.PRODUCT_NAME == null)
                    {
                        row.PRODUCT_NAME = System.String.Empty;
                    }
                    if (row.REMARKS == null)
                    {
                        row.REMARKS = System.String.Empty;
                    }
                    if (row.REMARK1 == null)
                    {
                        row.REMARK1 = System.String.Empty;
                    }
                    if (row.REMARK2 == null)
                    {
                        row.REMARK2 = System.String.Empty;
                    }
                    if (row.REMARK3 == null)
                    {
                        row.REMARK3 = System.String.Empty;
                    }
                    if (row.REMARK4 == null)
                    {
                        row.REMARK4 = System.String.Empty;
                    }
                    if (row.REMARK5 == null)
                    {
                        row.REMARK5 = System.String.Empty;
                    }
                    if (row.REMARK6 == null)
                    {
                        row.REMARK6 = System.String.Empty;
                    }
                    if (row.REMARK1 == null)
                    {
                        row.REMARK1 = System.String.Empty;
                    }

                    ListViewItem listItem = lvDetailsList.Items.Add(iCount.ToString()); // LN
                    listItem.SubItems.Add(string.Empty);                                // Status
                    listItem.SubItems.Add(row.STOCKCODE);                               // STKCode
                    listItem.SubItems.Add(row.APPENDIX1);                               // Appendix1
                    listItem.SubItems.Add(row.APPENDIX2);                               // Appendix2
                    listItem.SubItems.Add(row.APPENDIX3);                               // Appendix3

                    // Check STKCode already exsist
                    String sql      = String.Format("STKCODE = '{0}'", row.STOCKCODE);
                    var    oProduct = ProductEx.Get(sql);
                    if (oProduct == null)
                    {
                        lvDetailsList.Items[iCount - 1].Tag = "P"; // New Product
                    }
                    else
                    {
                        sql = String.Format("STKCODE = '{0}' AND APPENDIX1 = '{1}' AND APPENDIX2 = '{2}' AND APPENDIX3 = '{3}'",
                                            row.STOCKCODE,
                                            row.APPENDIX1,
                                            row.APPENDIX2,
                                            row.APPENDIX3);
                        oProduct = ProductEx.Get(sql);
                        if (oProduct == null)
                        {
                            lvDetailsList.Items[iCount - 1].Tag = "A"; // New Appendix/Class
                        }
                        else
                        {
                            productId = oProduct.ProductId;
                        }
                    }

                    listItem.SubItems.Add(row.COST.ToString("n2")); // Cost
                    if (row.COST == 0)
                    {
                        lvDetailsList.Items[iCount - 1].Tag += "C"; // No Cost
                        listItem.SubItems.Add("0.00");              // CostLocal
                    }
                    else
                    {
                        listItem.SubItems.Add((Convert.ToDecimal(row.COST) * Convert.ToDecimal(txtExchangeRate.Text.Length == 0 ? "1" : txtExchangeRate.Text)).ToString("n2")); // CostLocal
                    }

                    listItem.SubItems.Add(row.QTY.ToString("n0")); // Qty
                    if (row.QTY == 0)
                    {
                        lvDetailsList.Items[iCount - 1].Tag += "Q";     // No Qty
                    }
                    listItem.SubItems.Add(row.CLASS1);                  // Class1
                    listItem.SubItems.Add(row.CLASS2);                  // Class2
                    listItem.SubItems.Add(row.CLASS3);                  // Class3
                    listItem.SubItems.Add(row.CLASS4);                  // Class4
                    listItem.SubItems.Add(row.CLASS5);                  // Class5
                    listItem.SubItems.Add(row.CLASS6);                  // Class6
                    listItem.SubItems.Add(row.PRODUCT_NAME);            // ProductName
                    listItem.SubItems.Add(row.REMARKS);                 // Remarks
                    listItem.SubItems.Add(row.REMARK1);                 // Remark1
                    listItem.SubItems.Add(row.REMARK2);                 // Remark2
                    listItem.SubItems.Add(row.REMARK3);                 // Remark3
                    listItem.SubItems.Add(row.REMARK4);                 // Remark4
                    listItem.SubItems.Add(row.REMARK5);                 // Remark5
                    listItem.SubItems.Add(row.REMARK6);                 // Remark6
                    listItem.SubItems.Add(row.RETAIL_PRICE.ToString()); // Retail Price
                    if (row.RETAIL_PRICE == 0 && chkImportStockCode.Checked)
                    {
                        lvDetailsList.Items[iCount - 1].Tag += "R";                   // No Retail Price
                    }
                    listItem.SubItems.Add(row.RETAIL_DISCOUNT.ToString());            // Retail Discount
                    listItem.SubItems.Add(row.DISCOUNT_FOR_DISCOUNT_ITEM.ToString()); // Discount for Discount Item
                    listItem.SubItems.Add(productId.ToString());                      // ProductId
                }

                if (updatelvDetailStatus() <= 1)// 0 = no error, 1 = has alert, 2 = has error
                {
                    btnImport.Enabled = true;
                }
            }
        }
Beispiel #26
0
        private bool IsPostable(string headerId, ref DataTable errorTable)
        {
            bool isPostable = true;

            Guid id = Guid.Empty;

            if (Guid.TryParse(headerId, out id))
            {
                var oBatchHeader = StockTakeHeaderEx.Get(id);
                if (oBatchHeader != null)
                {
                    if (!CheckTxDate(oBatchHeader.TxDate.Value))
                    {
                        DataRow row = errorTable.NewRow();
                        row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                        row["TxNumber"]    = oBatchHeader.TxNumber;
                        row["STKCODE"]     = string.Empty;
                        row["APPENDIX1"]   = string.Empty;
                        row["APPENDIX2"]   = string.Empty;
                        row["APPENDIX3"]   = string.Empty;
                        row["ErrorReason"] = "Transaction date does not belong to current system month.";
                        row["PostDate"]    = DateTime.Now;

                        errorTable.Rows.Add(row);

                        isPostable = isPostable & false;
                    }

                    if (oBatchHeader.PostedOn.Value.Year > 1900)
                    {
                        DataRow row = errorTable.NewRow();
                        row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                        row["TxNumber"]    = oBatchHeader.TxNumber;
                        row["STKCODE"]     = string.Empty;
                        row["APPENDIX1"]   = string.Empty;
                        row["APPENDIX2"]   = string.Empty;
                        row["APPENDIX3"]   = string.Empty;
                        row["ErrorReason"] = "Transaction already had been posted! Cannot post again!";
                        row["PostDate"]    = DateTime.Now;

                        errorTable.Rows.Add(row);

                        isPostable = isPostable & false;
                    }

                    var detailList = StockTakeDetailsEx.GetByHeaderIdr(oBatchHeader.HeaderId);
                    foreach (var detail in detailList)
                    {
                        bool   retired = false;
                        string stk = string.Empty, a1 = string.Empty, a2 = string.Empty, a3 = string.Empty;

                        var oProduct = ProductEx.Get(detail.ProductId.Value);
                        if (oProduct != null)
                        {
                            stk     = oProduct.STKCODE;
                            a1      = oProduct.APPENDIX1;
                            a2      = oProduct.APPENDIX2;
                            a3      = oProduct.APPENDIX3;
                            retired = oProduct.Retired;
                        }

                        if (retired)
                        {
                            DataRow row = errorTable.NewRow();
                            row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                            row["TxNumber"]    = oBatchHeader.TxNumber;
                            row["STKCODE"]     = stk;
                            row["APPENDIX1"]   = a1;
                            row["APPENDIX2"]   = a2;
                            row["APPENDIX3"]   = a3;
                            row["ErrorReason"] = "Product does not exist or has been removed!";
                            row["PostDate"]    = DateTime.Now;

                            errorTable.Rows.Add(row);

                            isPostable = isPostable & false;
                        }

                        if (chkCheckVeQty.Checked && chkCheckVeQty.Visible)
                        {
                            decimal stkTtlQty = (detail.Book1Qty.Value + detail.Book2Qty.Value + detail.Book3Qty.Value + detail.Book4Qty.Value + detail.Book5Qty.Value + detail.HHTQty.Value) - detail.CapturedQty.Value;

                            //string sql = "ProductId = '" + detail.ProductId + "' AND WorkplaceId = '" + oBatchHeader.WorkplaceId.ToString() + "'";
                            var pw = ProductWorkplaceEx.Get(detail.ProductId.Value, oBatchHeader.WorkplaceId.Value);
                            if (pw != null)
                            {
                                if ((pw.CDQTY + stkTtlQty) < 0)
                                {
                                    DataRow row = errorTable.NewRow();
                                    row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                                    row["TxNumber"]    = oBatchHeader.TxNumber;
                                    row["STKCODE"]     = stk;
                                    row["APPENDIX1"]   = a1;
                                    row["APPENDIX2"]   = a2;
                                    row["APPENDIX3"]   = a3;
                                    row["ErrorReason"] = "Not enough stock for adjustment!";
                                    row["PostDate"]    = DateTime.Now;

                                    errorTable.Rows.Add(row);

                                    isPostable = isPostable & false;
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(isPostable);
        }
Beispiel #27
0
        private bool IsPostable(string headerId, ref DataTable errorTable)
        {
            bool isPostable = true;

            using (var ctx = new EF6.RT2020Entities())
            {
                Guid id = Guid.Empty;
                if (Guid.TryParse(headerId, out id))
                {
                    var oBatchHeader = InvtBatchADJ_HeaderEx.Get(id);
                    if (oBatchHeader != null)
                    {
                        if (!CheckTxDate(oBatchHeader.TxDate.Value))
                        {
                            #region 加一行
                            DataRow row = errorTable.NewRow();
                            row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                            row["TxNumber"]    = oBatchHeader.TxNumber;
                            row["STKCODE"]     = string.Empty;
                            row["APPENDIX1"]   = string.Empty;
                            row["APPENDIX2"]   = string.Empty;
                            row["APPENDIX3"]   = string.Empty;
                            row["ErrorReason"] = "Transaction date does not belong to current system month.";
                            row["PostDate"]    = DateTime.Now;

                            errorTable.Rows.Add(row);
                            #endregion
                            isPostable = isPostable & false;
                        }

                        if (oBatchHeader.Status == (int)EnumHelper.Status.Active && oBatchHeader.PostedBy != System.Guid.Empty)
                        {
                            #region 加一行
                            DataRow row = errorTable.NewRow();
                            row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                            row["TxNumber"]    = oBatchHeader.TxNumber;
                            row["STKCODE"]     = string.Empty;
                            row["APPENDIX1"]   = string.Empty;
                            row["APPENDIX2"]   = string.Empty;
                            row["APPENDIX3"]   = string.Empty;
                            row["ErrorReason"] = "Transaction already had been posted! Cannot post again!";
                            row["PostDate"]    = DateTime.Now;

                            errorTable.Rows.Add(row);
                            #endregion
                            isPostable = isPostable & false;
                        }

                        var detailList = ctx.InvtBatchADJ_Details.Where(x => x.HeaderId == oBatchHeader.HeaderId).AsNoTracking().ToList();
                        foreach (var detail in detailList)
                        {
                            bool   retired = false;
                            string stk = string.Empty, a1 = string.Empty, a2 = string.Empty, a3 = string.Empty;

                            var oProduct = ProductEx.Get(detail.ProductId);
                            if (oProduct != null)
                            {
                                stk     = oProduct.STKCODE;
                                a1      = oProduct.APPENDIX1;
                                a2      = oProduct.APPENDIX2;
                                a3      = oProduct.APPENDIX3;
                                retired = oProduct.Retired;
                            }

                            if (retired)
                            {
                                #region 加一行
                                DataRow row = errorTable.NewRow();
                                row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                                row["TxNumber"]    = oBatchHeader.TxNumber;
                                row["STKCODE"]     = stk;
                                row["APPENDIX1"]   = a1;
                                row["APPENDIX2"]   = a2;
                                row["APPENDIX3"]   = a3;
                                row["ErrorReason"] = "Product does not exist or has been removed!";
                                row["PostDate"]    = DateTime.Now;

                                errorTable.Rows.Add(row);
                                #endregion
                                isPostable = isPostable & false;
                            }

                            decimal qty = ProductHelper.GetOnHandQtyByWorkplaceId(detail.ProductId, oBatchHeader.WorkplaceId);
                            if ((qty + detail.Qty) < 0)
                            {
                                #region 加一行
                                DataRow row = errorTable.NewRow();
                                row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                                row["TxNumber"]    = oBatchHeader.TxNumber;
                                row["STKCODE"]     = stk;
                                row["APPENDIX1"]   = a1;
                                row["APPENDIX2"]   = a2;
                                row["APPENDIX3"]   = a3;
                                row["ErrorReason"] = "Product does not have enough on-hand qty!";
                                row["PostDate"]    = DateTime.Now;

                                errorTable.Rows.Add(row);
                                #endregion
                                isPostable = isPostable & false;
                            }
                        }

                        var oStaff = StaffEx.GetByStaffId(oBatchHeader.StaffId);
                        if (oStaff != null)
                        {
                            if (oStaff.Retired)
                            {
                                #region 加一行
                                DataRow row = errorTable.NewRow();
                                row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                                row["TxNumber"]    = oBatchHeader.TxNumber;
                                row["STKCODE"]     = string.Empty;
                                row["APPENDIX1"]   = string.Empty;
                                row["APPENDIX2"]   = string.Empty;
                                row["APPENDIX3"]   = string.Empty;
                                row["ErrorReason"] = "Staff does not exist or has been removed!";
                                row["PostDate"]    = DateTime.Now;

                                errorTable.Rows.Add(row);
                                #endregion
                                isPostable = isPostable & false;
                            }
                        }

                        var oInvtLedger = ctx.InvtLedgerHeader.Where(x => x.TxNumber == oBatchHeader.TxNumber && x.TxType == "ADJ").AsNoTracking().FirstOrDefault();
                        if (oInvtLedger != null)
                        {
                            #region 加一行
                            DataRow row = errorTable.NewRow();
                            row["HeaderId"]    = oBatchHeader.HeaderId.ToString();
                            row["TxNumber"]    = oBatchHeader.TxNumber;
                            row["STKCODE"]     = string.Empty;
                            row["APPENDIX1"]   = string.Empty;
                            row["APPENDIX2"]   = string.Empty;
                            row["APPENDIX3"]   = string.Empty;
                            row["ErrorReason"] = "Transaction existed in Inventory Ledger!";
                            row["PostDate"]    = DateTime.Now;

                            errorTable.Rows.Add(row);
                            #endregion
                            isPostable = isPostable & false;
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(isPostable);
        }
Beispiel #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public ProductEx GetEx(int productId)
        {
            ProductEx data = new ProductEx();
            List <ProductAttribute> listOfAttribute = new List <ProductAttribute>();
            List <ProductGallery>   listOfGallery   = new List <ProductGallery>();

            using (SqlConnection cn = GetConnection())
            {
                SqlCommand cmd = cn.CreateCommand();
                cmd.CommandText = @"Select * from ProductGallery where ProductID = @productId";
                cmd.Parameters.AddWithValue("@productId", productId);
                using (SqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    while (dbReader.Read())
                    {
                        listOfGallery.Add(new ProductGallery()
                        {
                            GalleryID    = Convert.ToInt32(dbReader["GalleryID"]),
                            ProductID    = Convert.ToInt32(dbReader["ProductID"]),
                            Photo        = Convert.ToString(dbReader["Photo"]),
                            Description  = Convert.ToString(dbReader["Description"]),
                            DisplayOrder = Convert.ToInt32(dbReader["DisplayOrder"]),
                            IsHidden     = Convert.ToBoolean(dbReader["IsHidden"])
                        });
                    }
                }
                data.Galleries = listOfGallery;
                cn.Close();
            }

            using (SqlConnection cn = GetConnection())
            {
                SqlCommand cmd = cn.CreateCommand();
                cmd.CommandText = @"SELECT *
		                            from Products
                                        inner join ProductAttributes on Products.ProductID = ProductAttributes.ProductID 
                                       Where Products.ProductID = @productId";
                cmd.Parameters.AddWithValue("@productId", productId);
                using (SqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    while (dbReader.Read())
                    {
                        listOfAttribute.Add(new ProductAttribute()
                        {
                            AttributeID    = Convert.ToInt32(dbReader["AttributeID"]),
                            ProductID      = Convert.ToInt32(dbReader["ProductID"]),
                            AttributeName  = Convert.ToString(dbReader["AttributeName"]),
                            AttributeValue = Convert.ToString(dbReader["AttributeValue"]),
                            DisplayOrder   = Convert.ToInt32(dbReader["DisplayOrder"])
                        });
                        data.CategoryID  = Convert.ToInt32(dbReader["CategoryID"]);
                        data.Photo       = Convert.ToString(dbReader["Photo"]);
                        data.Price       = Convert.ToDecimal(dbReader["Price"]);
                        data.SupplierID  = Convert.ToInt32(dbReader["SupplierID"]);
                        data.Unit        = Convert.ToString(dbReader["Unit"]);
                        data.ProductName = Convert.ToString(dbReader["ProductName"]);
                        data.ProductID   = Convert.ToInt32(dbReader["ProductID"]);
                    }
                }

                data.Attributes = listOfAttribute;
                cn.Close();
            }

            return(data);
        }
Beispiel #29
0
 public ApiMessage <string> Edit(ProductEx parm)
 {
     return(_dal.Edit(parm));
 }
Beispiel #30
0
        /// <summary>
        /// Gets the product code.
        /// </summary>
        private void GetProductCode()
        {
            var oProduct = ProductEx.Get("STKCODE IN (SELECT MIN(STKCODE) FROM Product)");

            if (oProduct != null)
            {
                switch (this.ViewerType)
                {
                case RT2020.Controls.InvtUtility.InvtOlapViewerType.QoH_ATS:
                case RT2020.Controls.InvtUtility.InvtOlapViewerType.QoH_ATS_WithCutOffDate:
                    this.txtFromStkCode.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.StockReorder:
                    this.txtFromStkCode_Reorder.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.StockIOHistory:
                    txtFromStkCode_IOHistory.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.OCInventory:
                    txtFromStkCode_OCInventory.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.DiscrepancyAudit:
                    txtFromStkCode_DiscrepancyAudit.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.StockTransfer:
                    txtFromStkCode_Transfer.Text = oProduct.STKCODE;
                    break;
                }
            }

            oProduct = ProductEx.Get("STKCODE IN (SELECT MAX(STKCODE) FROM Product)", "STKCODE");
            if (oProduct != null)
            {
                switch (this.ViewerType)
                {
                case RT2020.Controls.InvtUtility.InvtOlapViewerType.QoH_ATS:
                case RT2020.Controls.InvtUtility.InvtOlapViewerType.QoH_ATS_WithCutOffDate:
                    this.txtToStkCode.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.StockReorder:
                    this.txtToStkCode_Reorder.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.StockIOHistory:
                    txtToStkCode_IOHistory.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.OCInventory:
                    txtToStkCode_OCInventory.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.DiscrepancyAudit:
                    txtToStkCode_DiscrepancyAudit.Text = oProduct.STKCODE;
                    break;

                case RT2020.Controls.InvtUtility.InvtOlapViewerType.StockTransfer:
                    txtToStkCode_Transfer.Text = oProduct.STKCODE;
                    break;
                }
            }
        }