Exemple #1
0
        private void updateItem_barcode_SelectedIdxChg(object sender, EventArgs e)
        {
            Log.WriteLog(LogType.Trace, "come in updateItem_barcode_SelectedIdxChg");
            lConnectMsg.Text = " ";
            lBarcodeMsg.Text = " ";

            try
            {
                if (cbBarcode.SelectedIndex > -1)
                {
                    int         iBarcodeIdx = cbBarcode.SelectedIndex;
                    LTS.Barcode stBarcode   = listBar[iBarcodeIdx];
                    int         iBarcodeId  = stBarcode.BarcodeID;

                    LTS.Product stProduct = DAT.DataAccess.GetProduct().Where(i => i.BarcodeID == iBarcodeId).FirstOrDefault();
                    if (null == stProduct)
                    {
                        Log.WriteLog(LogType.Trace, "the barcode[" + iBarcodeId + "] does not band any product yet.");

                        lBarcodeMsg.Text = "the barcode[" + stBarcode.BarcodeNumber + "] is not band any product yet, please select another barcode";

                        return;
                    }

                    Log.WriteLog(LogType.Trace, "the barcode[" + iBarcodeId + "] is band with product[" + stProduct.ProductID + "]");
                    return;
                }
            }
            catch (Exception ex)
            {
                Log.WriteLog(LogType.Error, "error to change barcode index, the error msg is " + ex.Message + "");
            }

            return;
        }
        //Tiaan
        private void StockOut_Load(object sender, EventArgs e)
        {
            try
            {
                List <LTS.Item>    item    = new List <LTS.Item>();
                List <LTS.Barcode> barcode = new List <LTS.Barcode>();
                List <LTS.BookOut> bookOut = new List <LTS.BookOut>();
                List <LTS.Product> product = new List <LTS.Product>();
                List <LTS.User>    user    = new List <LTS.User>();
                item    = DAT.DataAccess.GetItem().Where(y => y.ItemStatus == false).ToList();
                barcode = DAT.DataAccess.GetBarcode().ToList();
                bookOut = DAT.DataAccess.GetBookOut().ToList();
                product = DAT.DataAccess.GetProduct();
                user    = DAT.DataAccess.GetUser().ToList();
                for (int i = 0; i < bookOut.Count; i++)
                {
                    LTS.Item    it = item.Where(a => a.ItemID == bookOut[i].ItemID).FirstOrDefault();
                    LTS.Product p  = product.Where(r => r.ProductID == it.ProductID).FirstOrDefault();
                    LTS.Barcode b  = barcode.Where(q => q.BarcodeID == p.BarcodeID).FirstOrDefault();
                    LTS.User    u  = user.Where(w => w.UserID == bookOut[i].UserID).FirstOrDefault();


                    dataGridView1.Rows.Add(bookOut[i].BookOutID, it.TagEPC, b.BarcodeNumber, p.ProductName,
                                           bookOut[i].Reason, bookOut[i].Project, bookOut[i].Date, u.UserName, u.UserSurname);
                }
                dataGridView1.ClearSelection();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
Exemple #3
0
 public static LTS.Barcode GetBarcodeItemByID(int?BarcodeID)
 {
     LTS.Barcode barcode = new LTS.Barcode();
     try
     {
         using (LTS.LTSBase access = new LTS.LTSDC())
         {
             barcode = access.Barcode.Where(o => o.BarcodeID == BarcodeID).FirstOrDefault();
         }
     }
     catch (Exception ex)
     {
     }
     return(barcode);
 }
Exemple #4
0
        public static int AddBarcode(LTS.Barcode barcode)
        {
            int?BarcodeID = -1;

            try
            {
                using (LTS.LTSBase access = new LTS.LTSDC())
                {
                    access.InsertBarcode(barcode.BarcodeNumber, ref BarcodeID);
                }
            }
            catch (Exception ex)
            {
            }
            return(BarcodeID.Value);
        }
Exemple #5
0
        public static bool UpdateBarcode(LTS.Barcode barcode)
        {
            bool completed = false;

            try
            {
                using (LTS.LTSBase access = new LTS.LTSDC())
                {
                    access.UpdateBarcode(barcode.BarcodeNumber, barcode.BarcodeID);
                    completed = true;
                }
            }
            catch (Exception ex)
            {
                completed = false;
            }
            return(completed);
        }
        //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!");
            }
        }
Exemple #7
0
        /*添加bracode*/
        private int addBarcode(string sBarcodeNumber, ref int iID)
        {
            LTS.Barcode stBarcode = new LTS.Barcode();;

            stBarcode.BarcodeNumber = this.tProduceBarcode.Text;

            /*category添加到数据库*/
            iID = DAT.DataAccess.AddBarcode(stBarcode);
            if (iID != -1)
            {
                Log.WriteLog(LogType.Trace, "success to insert barcode with number[" + stBarcode.BarcodeNumber + "] and id[" + iID + "]into db.");

                return(1);
            }
            else
            {
                Log.WriteLog(LogType.Error, "error to insert barcode with name[" + stBarcode.BarcodeNumber + "] into db.");

                return(0);
            }
        }
        //Margo
        private void StockBookOutRemoval_Load(object sender, EventArgs e)
        {
            try
            {
                st = DAT.DataAccess.GetStore().ToList();
                List <string> S = new List <string>();

                for (int x = 0; x < st.Count; x++)
                {
                    S.Add(st[x].StoreName);
                }
                comboBoxStore.DataSource = S;

                List <LTS.BookOut> bo = new List <LTS.BookOut>();
                bo = DAT.DataAccess.GetBookOut().ToList();

                for (int i = 0; i < bo.Count; i++)
                {
                    BookOutMain b = new BookOutMain();
                    b.BookOutID = bo[i].BookOutID;
                    b.itemID    = bo[i].ItemID;
                    b.UserID    = bo[i].UserID;
                    b.Reason    = bo[i].Reason;
                    b.Project   = bo[i].Project;
                    b.Date      = bo[i].Date;

                    LTS.Item it = new LTS.Item();
                    it           = DAT.DataAccess.GetItem().Where(u => u.ItemID == b.itemID).FirstOrDefault();
                    b.ItemStatus = it.ItemStatus;
                    b.EPC        = it.TagEPC;
                    b.ProductID  = it.ProductID;
                    b.StoreID    = it.StoreID;

                    //get the specific product and assign the info to the ItemMain object
                    LTS.Product p = new LTS.Product();
                    p                    = DAT.DataAccess.GetProduct().Where(h => h.ProductID == b.ProductID).FirstOrDefault();
                    b.ProductName        = p.ProductName;
                    b.ProductDescription = p.ProductDescription;
                    b.BrandID            = p.BrandID;
                    b.CategoryID         = p.CategoryID;
                    b.BarcodeID          = p.BarcodeID;

                    //get the specific store and assign the info to the ItemMain object
                    LTS.Store s = new LTS.Store();
                    s               = DAT.DataAccess.GetStore().Where(j => j.StoreID == b.StoreID).FirstOrDefault();
                    b.StoreName     = s.StoreName;
                    b.StoreLocation = s.StoreLocation;

                    //get the specific brand and assign the info to the ItemMain object
                    LTS.Brand br = new LTS.Brand();
                    br                 = DAT.DataAccess.GetBrand().Where(y => y.BrandID == b.BrandID).FirstOrDefault();
                    b.BrandName        = br.BrandName;
                    b.BrandDescription = br.BrandDescription;

                    //get the sepcific category and assign the info to the ItemMain object
                    LTS.Category c = new LTS.Category();
                    c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == b.CategoryID).FirstOrDefault();
                    b.CategoryName        = c.CategoryName;
                    b.CategoryDescription = c.CategoryDescription;

                    //get the sepcific category and assign the info to the ItemMain object
                    LTS.Barcode ba = new LTS.Barcode();
                    ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == b.BarcodeID).FirstOrDefault();
                    b.BarcodeNumber = ba.BarcodeNumber;

                    LTS.User us = new LTS.User();
                    us = DAT.DataAccess.GetUser().Where(h => h.UserID == b.UserID).FirstOrDefault();
                    b.UserIdentityNumber = us.UserIdentityNumber;
                    b.UserName           = us.UserName;
                    b.UserSurname        = us.UserSurname;

                    bom.Add(b);

                    dataGridView1.Rows.Add(b.BookOutID, b.EPC, b.BarcodeNumber, b.ProductName, b.Reason, b.Project, b.Date, b.UserName, b.UserSurname);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
        //Devon
        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                whatCheck = "All";
                dataGridView2.Rows.Clear();
                List <LTS.Item> i = new List <LTS.Item>();
                i = DAT.DataAccess.GetItem().ToList();//list from db


                for (int x = 0; x < i.Count; x++)
                {
                    ItemMain im = new ItemMain();
                    //assign the item info to the ItemMain object
                    im.itemID     = i[x].ItemID;
                    im.EPC        = i[x].TagEPC;
                    im.ItemStatus = i[x].ItemStatus;
                    im.ProductID  = i[x].ProductID;
                    im.StoreID    = i[x].StoreID;

                    //get the specific product and assign the info to the ItemMain object
                    LTS.Product p = new LTS.Product();
                    p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault();
                    im.ProductName        = p.ProductName;
                    im.ProductDescription = p.ProductDescription;
                    im.BrandID            = p.BrandID;
                    im.CategoryID         = p.CategoryID;
                    im.BarcodeID          = p.BarcodeID;

                    //get the specific store and assign the info to the ItemMain object
                    LTS.Store s = new LTS.Store();
                    s                = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault();
                    im.StoreName     = s.StoreName;
                    im.StoreLocation = s.StoreLocation;

                    //get the specific brand and assign the info to the ItemMain object
                    LTS.Brand b = new LTS.Brand();
                    b                   = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault();
                    im.BrandName        = b.BrandName;
                    im.BrandDescription = b.BrandDescription;

                    //get the sepcific category and assign the info to the ItemMain object
                    LTS.Category c = new LTS.Category();
                    c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault();
                    im.CategoryName        = c.CategoryName;
                    im.CategoryDescription = c.CategoryDescription;

                    //get the sepcific category and assign the info to the ItemMain object
                    LTS.Barcode ba = new LTS.Barcode();
                    ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault();
                    im.BarcodeNumber = ba.BarcodeNumber;

                    imList.Add(im);

                    dataGridView2.Rows.Add(i[x].ItemID, i[x].TagEPC, p.ProductName, p.ProductDescription, ba.BarcodeNumber, b.BrandName, c.CategoryName
                                           , i[x].ItemStatus, s.StoreName);
                }
            }
            else
            {
                dataGridView2.Rows.Clear();
            }
        }
        //Devon
        private void button1_Click(object sender, EventArgs e)
        {
            dataGridView2.Rows.Clear();
            string comboVal = comboBoxStore.SelectedItem.ToString();
            int    sIndex   = comboBoxStore.SelectedIndex;

            LTS.Store       st      = listS[sIndex];
            int             storeID = st.StoreID;
            List <LTS.Item> i;

            if (whatCheck == "OutOfStock")
            {
                i = DAT.DataAccess.GetItem().Where(f => f.StoreID == storeID && f.ItemStatus == false).ToList();
            }
            else if (whatCheck == "InStock")
            {
                i = DAT.DataAccess.GetItem().Where(f => f.StoreID == storeID && f.ItemStatus == true).ToList();
            }
            else
            {
                i = DAT.DataAccess.GetItem().Where(f => f.StoreID == storeID).ToList();
            }

            for (int x = 0; x < i.Count; x++)
            {
                ItemMain im = new ItemMain();
                //assign the item info to the ItemMain object
                im.itemID     = i[x].ItemID;
                im.EPC        = i[x].TagEPC;
                im.ItemStatus = i[x].ItemStatus;
                im.ProductID  = i[x].ProductID;
                im.StoreID    = i[x].StoreID;

                //get the specific product and assign the info to the ItemMain object
                LTS.Product p = new LTS.Product();
                p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault();
                im.ProductName        = p.ProductName;
                im.ProductDescription = p.ProductDescription;
                im.BrandID            = p.BrandID;
                im.CategoryID         = p.CategoryID;
                im.BarcodeID          = p.BarcodeID;

                //get the specific store and assign the info to the ItemMain object
                LTS.Store s = new LTS.Store();
                s                = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault();
                im.StoreName     = s.StoreName;
                im.StoreLocation = s.StoreLocation;

                //get the specific brand and assign the info to the ItemMain object
                LTS.Brand b = new LTS.Brand();
                b                   = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault();
                im.BrandName        = b.BrandName;
                im.BrandDescription = b.BrandDescription;

                //get the sepcific category and assign the info to the ItemMain object
                LTS.Category c = new LTS.Category();
                c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault();
                im.CategoryName        = c.CategoryName;
                im.CategoryDescription = c.CategoryDescription;

                //get the sepcific category and assign the info to the ItemMain object
                LTS.Barcode ba = new LTS.Barcode();
                ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault();
                im.BarcodeNumber = ba.BarcodeNumber;

                imList.Add(im);

                dataGridView2.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName
                                       , im.ItemStatus, im.StoreName);
            }
        }
Exemple #11
0
        //Tiaan
        private void BookStockOut_Load(object sender, EventArgs e)
        {
            try
            {
                imList = new List <ItemMain>();

                item = DAT.DataAccess.GetItem().Where(u => u.ItemStatus == true).ToList();
                if (item != null)
                {
                    for (int x = 0; x < item.Count; x++)
                    {
                        ItemMain im = new ItemMain();
                        //assign the item info to the ItemMain object
                        im.itemID     = item[x].ItemID;
                        im.EPC        = item[x].TagEPC;
                        im.ItemStatus = item[x].ItemStatus;
                        im.ProductID  = item[x].ProductID;
                        im.StoreID    = item[x].StoreID;

                        //get the specific product and assign the info to the ItemMain object
                        LTS.Product p = new LTS.Product();

                        p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault();

                        im.ProductName        = p.ProductName;
                        im.ProductDescription = p.ProductDescription;
                        im.BrandID            = p.BrandID;
                        im.CategoryID         = p.CategoryID;

                        im.BarcodeID = p.BarcodeID;


                        //get the specific store and assign the info to the ItemMain object
                        LTS.Store s = new LTS.Store();
                        s                = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault();
                        im.StoreName     = s.StoreName;
                        im.StoreLocation = s.StoreLocation;

                        //get the specific brand and assign the info to the ItemMain object
                        LTS.Brand b = new LTS.Brand();
                        b                   = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault();
                        im.BrandName        = b.BrandName;
                        im.BrandDescription = b.BrandDescription;


                        //get the sepcific category and assign the info to the ItemMain object
                        LTS.Category c = new LTS.Category();
                        c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault();
                        im.CategoryName        = c.CategoryName;
                        im.CategoryDescription = c.CategoryDescription;

                        //get the sepcific category and assign the info to the ItemMain object
                        LTS.Barcode ba = new LTS.Barcode();
                        ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault();
                        im.BarcodeNumber = ba.BarcodeNumber;

                        imList.Add(im);
                        dataGridView1.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName
                                               , im.ItemStatus, im.StoreName);
                    }
                }


                st = new List <LTS.Store>();
                st = DAT.DataAccess.GetStore().ToList();
                List <string> S = new List <string>();

                for (int x = 0; x < st.Count; x++)
                {
                    S.Add(st[x].StoreName);
                }
                comboBoxStore.DataSource = S;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
        //Devon
        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                if (radioButton4.Checked)
                {
                    whatCheck = "OutOfStock";

                    dataGridView2.Rows.Clear();
                    List <LTS.Item> i = new List <LTS.Item>();
                    i = DAT.DataAccess.GetItem().Where(s => s.ItemStatus == false).ToList();//list from db
                    List <ItemMain> imList = new List <ItemMain>();

                    for (int x = 0; x < i.Count; x++)
                    {
                        ItemMain im = new ItemMain();
                        //assign the item info to the ItemMain object
                        im.itemID     = i[x].ItemID;
                        im.EPC        = i[x].TagEPC;
                        im.ItemStatus = i[x].ItemStatus;
                        im.ProductID  = i[x].ProductID;
                        im.StoreID    = i[x].StoreID;

                        //get the specific product and assign the info to the ItemMain object
                        LTS.Product p = new LTS.Product();
                        p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault();
                        im.ProductName        = p.ProductName;
                        im.ProductDescription = p.ProductDescription;
                        im.BrandID            = p.BrandID;
                        im.CategoryID         = p.CategoryID;
                        im.BarcodeID          = p.BarcodeID;

                        //get the specific store and assign the info to the ItemMain object
                        LTS.Store s = new LTS.Store();
                        s                = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault();
                        im.StoreName     = s.StoreName;
                        im.StoreLocation = s.StoreLocation;

                        //get the specific brand and assign the info to the ItemMain object
                        LTS.Brand b = new LTS.Brand();
                        b                   = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault();
                        im.BrandName        = b.BrandName;
                        im.BrandDescription = b.BrandDescription;

                        //get the sepcific category and assign the info to the ItemMain object
                        LTS.Category c = new LTS.Category();
                        c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault();
                        im.CategoryName        = c.CategoryName;
                        im.CategoryDescription = c.CategoryDescription;

                        //get the sepcific category and assign the info to the ItemMain object
                        LTS.Barcode ba = new LTS.Barcode();
                        ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault();
                        im.BarcodeNumber = ba.BarcodeNumber;

                        imList.Add(im);

                        dataGridView2.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName
                                               , im.ItemStatus, im.StoreName);
                    }
                }
                else
                {
                    dataGridView2.Rows.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
Exemple #13
0
        private void item_radioAll_click(object sender, EventArgs e)
        {
            Log.WriteLog(LogType.Trace, "come in item_radioAll_click");

            if (radioAll.Checked)
            {
                try
                {
                    //从数据库中读取item记录到内存
                    List <LTS.Item> i = new List <LTS.Item>();
                    i = DAT.DataAccess.GetItem().ToList();
                    List <ItemMain> imList = new List <ItemMain>();

                    //根据item记录字段,组装厂家,类型等信息到内存
                    for (int x = 0; x < i.Count; x++)
                    {
                        ItemMain im = new ItemMain();


                        //将item记录信息保存到内存
                        im.itemID     = i[x].ItemID;
                        im.EPC        = i[x].TagEPC;
                        im.ItemStatus = i[x].ItemStatus;
                        im.ProductID  = i[x].ProductID;
                        im.StoreID    = i[x].StoreID;

                        Log.WriteLog(LogType.Trace, "goto get item[" + im.itemID + "] info into memery:epc[" + im.EPC + "], status[{" + im.ItemStatus + "}], pruduct id[{" + im.ProductID + "}], store id[{" + im.StoreID + "}]");

                        //组装item的产品信息
                        LTS.Product p = new LTS.Product();
                        p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault();
                        im.ProductName        = p.ProductName;
                        im.ProductDescription = p.ProductDescription;
                        im.BrandID            = p.BrandID;
                        im.CategoryID         = p.CategoryID;
                        im.BarcodeID          = p.BarcodeID;

                        //组装item的store信息
                        LTS.Store s = new LTS.Store();
                        s                = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault();
                        im.StoreName     = s.StoreName;
                        im.StoreLocation = s.StoreLocation;

                        //组装item的厂家信息
                        LTS.Brand b = new LTS.Brand();
                        b                   = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault();
                        im.BrandName        = b.BrandName;
                        im.BrandDescription = b.BrandDescription;

                        //组装item的类型信息
                        LTS.Category c = new LTS.Category();
                        c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault();
                        im.CategoryName        = c.CategoryName;
                        im.CategoryDescription = c.CategoryDescription;

                        //组装item的条形码信息
                        LTS.Barcode ba = new LTS.Barcode();
                        ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault();
                        im.BarcodeNumber = ba.BarcodeNumber;

                        //item完整信息添加到list中,并在控件中展示
                        imList.Add(im);
                        dataGridView1.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName
                                               , im.ItemStatus, im.StoreName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteLog(LogType.Error, "error to show item info into data grid view for all");
                }
            }
            else
            {
                dataGridView1.Rows.Clear();
            }
        }
Exemple #14
0
        private void updateItem_load(object sender, EventArgs e)
        {
            Log.WriteLog(LogType.Trace, "come in updateItem_load");


            //load store names into combo box from db
            listS = DAT.DataAccess.GetStore().ToList();
            List <string> S = new List <string>();

            for (int x = 0; x < listS.Count; x++)
            {
                S.Add(listS[x].StoreName);
            }
            cbStore.DataSource = S;
            if (listS.Count > 1)
            {
                cbStore.SelectedIndex = 0;
            }

            //load barcode into combo box from db
            listBar = DAT.DataAccess.GetBarcode().ToList();
            List <string> Ba = new List <string>();

            for (int x = 0; x < listBar.Count; x++)
            {
                Ba.Add(listBar[x].BarcodeNumber);
            }

            cbBarcode.DataSource = Ba;  //会触发select index change 事件
            if (listBar.Count > 1)
            {
                cbBarcode.SelectedIndex = 0;
            }


            List <LTS.Item> i = new List <LTS.Item>();

            i      = DAT.DataAccess.GetItem().ToList();//list from db
            imList = new List <ItemMain>();

            for (int x = 0; x < i.Count; x++)
            {
                ItemMain im = new ItemMain();
                //assign the item info to the ItemMain object
                im.itemID     = i[x].ItemID;
                im.EPC        = i[x].TagEPC;
                im.ItemStatus = i[x].ItemStatus;
                im.ProductID  = i[x].ProductID;
                im.StoreID    = i[x].StoreID;

                Log.WriteLog(LogType.Trace, "goto load item[" + im.itemID + "] detail info from database, the summary info is:epc[" + im.EPC + "], item status[" + im.ItemStatus + "]," +
                             "product id[" + im.ProductID + "], store id[" + im.StoreID + "]");

                //get the specific product and assign the info to the ItemMain object
                LTS.Product p = new LTS.Product();

                p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault();
                if (null == p)
                {
                    Log.WriteLog(LogType.Error, "error to get product[" + im.ProductID + "] info while loading item[" + im.itemID + "] detail info.");
                    continue;
                }

                im.ProductName        = p.ProductName;
                im.ProductDescription = p.ProductDescription;
                im.BrandID            = p.BrandID;
                im.CategoryID         = p.CategoryID;
                im.BarcodeID          = p.BarcodeID;

                //get the specific store and assign the info to the ItemMain object
                LTS.Store s = new LTS.Store();
                s = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault();
                if (null == s)
                {
                    Log.WriteLog(LogType.Error, "error to get store[" + im.StoreID + "] info while loading item[" + im.itemID + "] detail info.");
                    continue;
                }
                im.StoreName     = s.StoreName;
                im.StoreLocation = s.StoreLocation;

                //get the specific brand and assign the info to the ItemMain object
                LTS.Brand b = new LTS.Brand();
                b = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault();
                if (null == b)
                {
                    Log.WriteLog(LogType.Error, "error to get brand[" + im.BrandID + "] info while loading item[" + im.itemID + "] detail info.");
                    continue;
                }
                im.BrandName        = b.BrandName;
                im.BrandDescription = b.BrandDescription;

                //get the sepcific category and assign the info to the ItemMain object
                LTS.Category c = new LTS.Category();
                c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault();
                if (null == c)
                {
                    Log.WriteLog(LogType.Error, "error to get category[" + im.CategoryID + "] info while loading item[" + im.itemID + "] detail info.");
                    continue;
                }
                im.CategoryName        = c.CategoryName;
                im.CategoryDescription = c.CategoryDescription;

                //get the sepcific category and assign the info to the ItemMain object
                LTS.Barcode ba = new LTS.Barcode();
                ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault();
                if (null == ba)
                {
                    Log.WriteLog(LogType.Error, "error to get barcode[" + im.BarcodeID + "] info while loading item[" + im.itemID + "] detail info.");
                    continue;
                }
                im.BarcodeNumber = ba.BarcodeNumber;

                imList.Add(im);
                dgvItem.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName
                                 , im.ItemStatus, im.StoreName);

                Log.WriteLog(LogType.Trace, "success to load item[" + im.itemID + "] detail info:epc[" + im.EPC + "], productName[" + im.ProductName + "], productDesciption[" + im.ProductDescription + "]" +
                             "barcode[" + im.BarcodeNumber + "], brandName[" + im.BrandName + "], categoryName[" + im.CategoryName + "], itemStatus[" + im.ItemStatus + "], storeName[" + im.StoreName + "]");
            }
        }
Exemple #15
0
        //Devon
        private void UpdateStock_Load(object sender, EventArgs e)
        {
            try
            {
                ChangeView <SearchWithEPC>();
                //load store names into combo box from db
                listS = DAT.DataAccess.GetStore().ToList();
                List <string> S = new List <string>();

                for (int x = 0; x < listS.Count; x++)
                {
                    S.Add(listS[x].StoreName);
                }
                comboBoxStore.DataSource = S;

                //load barcode into combo box from db
                listBar = DAT.DataAccess.GetBarcode().ToList();
                List <string> Ba = new List <string>();

                for (int x = 0; x < listBar.Count; x++)
                {
                    Ba.Add(listBar[x].BarcodeNumber);
                }
                comboBox1.DataSource = Ba;

                List <LTS.Item> i = new List <LTS.Item>();
                i      = DAT.DataAccess.GetItem().ToList();//list from db
                imList = new List <ItemMain>();

                for (int x = 0; x < i.Count; x++)
                {
                    ItemMain im = new ItemMain();
                    //assign the item info to the ItemMain object
                    im.itemID     = i[x].ItemID;
                    im.EPC        = i[x].TagEPC;
                    im.ItemStatus = i[x].ItemStatus;
                    im.ProductID  = i[x].ProductID;
                    im.StoreID    = i[x].StoreID;

                    //get the specific product and assign the info to the ItemMain object
                    LTS.Product p = new LTS.Product();

                    p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault();

                    im.ProductName        = p.ProductName;
                    im.ProductDescription = p.ProductDescription;
                    im.BrandID            = p.BrandID;
                    im.CategoryID         = p.CategoryID;

                    im.BarcodeID = p.BarcodeID;

                    //get the specific store and assign the info to the ItemMain object
                    LTS.Store s = new LTS.Store();
                    s                = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault();
                    im.StoreName     = s.StoreName;
                    im.StoreLocation = s.StoreLocation;

                    //get the specific brand and assign the info to the ItemMain object
                    LTS.Brand b = new LTS.Brand();
                    b                   = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault();
                    im.BrandName        = b.BrandName;
                    im.BrandDescription = b.BrandDescription;

                    //get the sepcific category and assign the info to the ItemMain object
                    LTS.Category c = new LTS.Category();
                    c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault();
                    im.CategoryName        = c.CategoryName;
                    im.CategoryDescription = c.CategoryDescription;

                    //get the sepcific category and assign the info to the ItemMain object
                    LTS.Barcode ba = new LTS.Barcode();
                    ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault();
                    im.BarcodeNumber = ba.BarcodeNumber;

                    imList.Add(im);
                    dataGridView2.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName
                                           , im.ItemStatus, im.StoreName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
Exemple #16
0
        //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!");
            }
        }
Exemple #17
0
        //Marius
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                brandlbl.Visible      = false;
                catlbl.Visible        = false;
                lblBarcodeVal.Visible = false;
                lblDescVal.Visible    = false;
                lblNameVal.Visible    = false;
                int getBarcodeID;
                try
                {
                    LTS.Product prod = new LTS.Product();

                    LTS.Brand brand = new LTS.Brand();
                    brand = DAT.DataAccess.GetBrand().Where(o => o.BrandName == comboBoxBrand.SelectedItem.ToString()).FirstOrDefault();
                    if (brand != null)
                    {
                        prod.BrandID = brand.BrandID;
                    }
                    else
                    {
                        brandlbl.Visible = true;
                    }

                    LTS.Category cat = new LTS.Category();
                    cat = DAT.DataAccess.GetCategory().Where(o => o.CategoryName == comboBoxCategory.SelectedItem.ToString()).FirstOrDefault();

                    if (cat != null)
                    {
                        prod.CategoryID = cat.CategoryID;
                    }
                    else
                    {
                        catlbl.Visible = true;
                    }



                    LTS.Barcode barc = new LTS.Barcode();
                    if (listBar.Where(u => u.BarcodeNumber == tbBarcode.Text).FirstOrDefault() == null)
                    {
                        barc.BarcodeNumber = tbBarcode.Text;
                    }
                    else
                    {
                        lblBarcodeVal.Visible = true;
                        lblBarcodeVal.Text    = "The barcode value is already in use";
                    }

                    //validation
                    if (tbProdName.Text == "")
                    {
                        lblNameVal.Visible = true;
                        lblNameVal.Text    = "Please enter a product name";
                    }
                    if (tbProdDesc.Text == "")
                    {
                        lblDescVal.Visible = true;
                        lblDescVal.Text    = "Please enter a product description";
                    }
                    if (tbBarcode.Text == "")
                    {
                        lblBarcodeVal.Visible = true;
                        lblBarcodeVal.Text    = "Please enter a barcode number";
                    }

                    int ok;
                    if (lblBarcodeVal.Visible == false && lblDescVal.Visible == false && lblNameVal.Visible == false && brandlbl.Visible == false && catlbl.Visible == false)
                    {
                        getBarcodeID = DAT.DataAccess.AddBarcode(barc);
                        if (getBarcodeID != -1)
                        {
                            prod.BarcodeID          = getBarcodeID;
                            prod.ProductName        = tbProdName.Text;
                            prod.ProductDescription = tbProdDesc.Text;
                            ok = DAT.DataAccess.AddProduct(prod);

                            if (ok == -1)
                            {
                                DAT.DataAccess.RemoveBarcode(prod.BarcodeID);
                                MessageBox.Show("Sorry something went wrong, the Product was not Added!");
                                ((Main)this.Parent.Parent).ChangeView <Pages.Products.Product>();
                            }
                            else
                            {
                                MessageBox.Show("The Product was added successfully!");
                                ((Main)this.Parent.Parent).ChangeView <Pages.Products.Product>();
                            }
                        }
                        else
                        {
                            lblBarcodeVal.Visible = true;
                            lblBarcodeVal.Text    = "The barcode could not be created!";
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (DialogResult.OK == MessageBox.Show("The Product was not added successfully!"))
                    {
                        ((Main)this.Parent.Parent).ChangeView <Pages.Products.Product>();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
Exemple #18
0
        private void item_radioOutStock_click(object sender, EventArgs e)
        {
            Log.WriteLog(LogType.Trace, "come in item_radioOutStock_click");
            if (radioOutStock.Checked)
            {
                try
                {
                    List <LTS.Item> i = new List <LTS.Item>();
                    i = DAT.DataAccess.GetItem().Where(s => s.ItemStatus == false).ToList();    //list from db
                    List <ItemMain> imList = new List <ItemMain>();

                    for (int x = 0; x < i.Count; x++)
                    {
                        ItemMain im = new ItemMain();
                        //assign the item info to the ItemMain object
                        im.itemID     = i[x].ItemID;
                        im.EPC        = i[x].TagEPC;
                        im.ItemStatus = i[x].ItemStatus;
                        im.ProductID  = i[x].ProductID;
                        im.StoreID    = i[x].StoreID;

                        //get the specific product and assign the info to the ItemMain object
                        LTS.Product p = new LTS.Product();
                        p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault();
                        im.ProductName        = p.ProductName;
                        im.ProductDescription = p.ProductDescription;
                        im.BrandID            = p.BrandID;
                        im.CategoryID         = p.CategoryID;
                        im.BarcodeID          = p.BarcodeID;

                        //get the specific store and assign the info to the ItemMain object
                        LTS.Store s = new LTS.Store();
                        s                = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault();
                        im.StoreName     = s.StoreName;
                        im.StoreLocation = s.StoreLocation;

                        //get the specific brand and assign the info to the ItemMain object
                        LTS.Brand b = new LTS.Brand();
                        b                   = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault();
                        im.BrandName        = b.BrandName;
                        im.BrandDescription = b.BrandDescription;

                        //get the sepcific category and assign the info to the ItemMain object
                        LTS.Category c = new LTS.Category();
                        c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault();
                        im.CategoryName        = c.CategoryName;
                        im.CategoryDescription = c.CategoryDescription;

                        //get the sepcific category and assign the info to the ItemMain object
                        LTS.Barcode ba = new LTS.Barcode();
                        ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault();
                        im.BarcodeNumber = ba.BarcodeNumber;

                        imList.Add(im);
                        dataGridView1.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName
                                               , im.ItemStatus, im.StoreName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteLog(LogType.Error, "error to show item info into data grid view for out stock ");
                }
            }
            else
            {
                dataGridView1.Rows.Clear();
            }
        }