示例#1
0
        private void updateItem_update_click(object sender, EventArgs e)
        {
            int iItemId, iStortId, iBarcodeId;
            int iStortIdx, iBarcodeIdx;


            label4.Visible = false;
            label7.Visible = false;
            iItemId        = giItemId;

            Log.WriteLog(LogType.Trace, "come in updateItem_update_click");


            //判断epc合法性
            if (tbEpc.Text == "")
            {
                label4.Text    = "Please enter the RFID Tag!";
                label4.Visible = true;
            }

            iStortIdx   = cbStore.SelectedIndex;
            iBarcodeIdx = cbBarcode.SelectedIndex;
            //判断store和barcode的合法性
            if (iStortIdx == -1 || iBarcodeIdx == -1)
            {
                Log.WriteLog(LogType.Warning, "the store or the barcode has not change yet");
                MessageBox.Show("the store or the barcode has not change yet, please change them.");
                label7.Visible = true;

                return;
            }

            iStortId   = listS[iStortIdx].StoreID;
            iBarcodeId = listBar[iBarcodeIdx].BarcodeID;


            try
            {
                //判断barcode是否绑定了product
                LTS.Product stProduct = new LTS.Product();
                stProduct = DAT.DataAccess.GetProduct().Where(f => f.BarcodeID == iBarcodeId).FirstOrDefault();
                if (null == stProduct)
                {
                    Log.WriteLog(LogType.Warning, "the barcode[" + iBarcodeId + "] has not band with product.");
                    MessageBox.Show("the barcode[" + iBarcodeId + "] has not band with product, please change another barcode.");

                    return;
                }
                Log.WriteLog(LogType.Trace, "success to get product[" + stProduct.ProductID + "] which band with barcode[" + iBarcodeId + "]");

                //判断epc是否被使用
                if (tbEpc.Text != oldEPC)
                {
                    LTS.Item stTmpItem = DAT.DataAccess.GetItem().Where(i => i.TagEPC == tbEpc.Text).FirstOrDefault();
                    if (stTmpItem != null)
                    {
                        Log.WriteLog(LogType.Warning, "the ecp[" + tbEpc.Text + "] already been use by item[" + stTmpItem.ItemID + "].Please enter a different one.");

                        label4.Text    = "ecp[" + tbEpc.Text + "] already been use! Please enter a different one.";
                        label4.Visible = true;
                        return;
                    }
                }

                //判断item是否存在
                LTS.Item stItem = DAT.DataAccess.GetItem().Where(d => d.ItemID == iItemId).FirstOrDefault();
                if (null == stItem)
                {
                    Log.WriteLog(LogType.Error, "error to get item[" + iItemId + "] from database");
                    MessageBox.Show("error to get item[" + iItemId + "] from database");
                    return;
                }
                Log.WriteLog(LogType.Trace, "success to get item[" + iItemId + "] from database");



                //更新item信息
                stItem.ProductID = stProduct.ProductID;
                stItem.StoreID   = iStortId; stItem.StoreID = iStortId;

                if (tbEpc.Text != oldEPC)
                {
                    stItem.TagEPC = tbEpc.Text;
                }


                //信息保存到数据库
                if (DAT.DataAccess.UpdateItem(stItem))
                {
                    Log.WriteLog(LogType.Trace, "success to change item[" + iItemId + "] ecp from[" + oldEPC + "]into[" + tbEpc.Text + "] witch band product with barcode[" + iBarcodeId + "] in store[" + iStortId + "]");

                    MessageBox.Show("Item has been updated!");
                    ((Main)this.Parent.Parent).ChangeView <Pages.Items.Items>();
                }
                else
                {
                    Log.WriteLog(LogType.Trace, "error to change item[" + iItemId + "] ecp from[" + oldEPC + "]into[" + tbEpc.Text + "] witch band product with barcode[" + iBarcodeId + "] in store[" + iStortId + "]");
                    MessageBox.Show("error to update item info!");
                }
            }
            catch (Exception ex)
            {
                Log.WriteLog(LogType.Error, "there is something wrong during to update item. the error msg is " + ex.Message + "");

                MessageBox.Show("there is something wrong during to update item!");
                return;
            }
        }
示例#2
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 + "]");
            }
        }
示例#3
0
        //添加一个item,(一个epc只能对应一个item)
        private void addItem_add_click(object sender, EventArgs e)
        {
            Log.WriteLog(LogType.Trace, "addItem_add_click");
            lStoreMsg.Visible   = false;
            label16.Visible     = false;
            lBarcodeMsg.Visible = false;
            lEpcMsg2.Visible    = false;
            lEpcMsg1.Visible    = false;

            try
            {
                //判断参数合法性
                int storeIndex   = cbStore.SelectedIndex;
                int barcodeIndex = cbBarcode.SelectedIndex;


                if (storeIndex == -1)
                {
                    lStoreMsg.Visible = true;
                    Log.WriteLog(LogType.Error, "the store is not select");

                    return;
                }
                if (barcodeIndex == -1)
                {
                    label16.Visible = true;
                    Log.WriteLog(LogType.Error, "the barcode is not select");
                    return;
                }
                if (textBox2.Text == "")
                {
                    lEpcMsg1.Visible = true;
                    Log.WriteLog(LogType.Error, "the ecp string is null");
                    return;
                }

                //判断barcode是否绑定了product
                int         barcodeID = listBar[barcodeIndex].BarcodeID;
                LTS.Product p         = DAT.DataAccess.GetProduct().Where(a => a.BarcodeID == barcodeID).FirstOrDefault();
                if (p == null)
                {
                    lBarcodeMsg.Visible = true;
                    Log.WriteLog(LogType.Error, "the barcode[" + barcodeID + "] is not band any product");
                    return;
                }
                Log.WriteLog(LogType.Trace, "the barcode[" + barcodeID + "] is band with product[" + p.ProductID + "]");


                //判断这个epc是否已经被使用,一个epc只能对应一个item
                LTS.Item stItem = DAT.DataAccess.GetItem().Where(b => b.TagEPC == textBox2.Text).FirstOrDefault();
                if (stItem != null)
                {
                    lEpcMsg2.Text = "epc[" + textBox2.Text + "] alreasy be use! Please enter a different one.";

                    Log.WriteLog(LogType.Trace, "the ecp[" + textBox2.Text + "] has already exist, please enter a different one");

                    lEpcMsg2.Visible = true;
                    return;
                }


                //保存item信息
                LTS.Item stNewItem = new LTS.Item();
                if (stNewItem == null)
                {
                    Log.WriteLog(LogType.Error, "Error to get new item memery");
                    MessageBox.Show("error to get memery from system");
                    return;
                }

                stNewItem.StoreID    = listS[storeIndex].StoreID;
                stNewItem.TagEPC     = textBox2.Text;
                stNewItem.ProductID  = p.ProductID;
                stNewItem.ItemStatus = true;



                int returnedID = DAT.DataAccess.AddItem(stNewItem);
                if (returnedID == -1)
                {
                    Log.WriteLog(LogType.Trace, "errir to add item with epc[" + stNewItem.TagEPC + "] and produce[" + stNewItem.ProductID + "] into store[" + stNewItem.StoreID + "]");
                    MessageBox.Show("Item was not added to the database!");
                }
                else
                {
                    Log.WriteLog(LogType.Trace, "success to add item[" + returnedID + "] with epc[" + stNewItem.TagEPC + "] and produce[" + stNewItem.ProductID + "] into store[" + stNewItem.StoreID + "]");
                    MessageBox.Show("Item was succesfully added to the database");
                    ((Main)this.Parent.Parent).ChangeView <Pages.Items.Items>();
                }

                return;
            }
            catch (Exception ex)
            {
                Log.WriteLog(LogType.Error, "error to add item into database, the error msg is " + ex.Message + "");

                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
示例#4
0
        /*当barcode改变时,用来实时显示该barcode的产品,厂家,类型信息。(一个barcode只能对应一个product)*/
        private void addItem_barcode_selectedIdxChg(object sender, EventArgs e)
        {
            Log.WriteLog(LogType.Trace, "come in addItem_barcode_selectedIdxChg");

            lBarcodeMsg.Visible = false;
            try
            {
                cbBarcode.DropDownStyle      = System.Windows.Forms.ComboBoxStyle.DropDown;
                cbBarcode.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
                cbBarcode.AutoCompleteSource = AutoCompleteSource.ListItems;

                try
                {
                    /*获取barcode信息*/
                    int bIndex = cbBarcode.SelectedIndex;
                    int barID  = listBar[bIndex].BarcodeID;

                    Log.WriteLog(LogType.Trace, "the barcord[" + barID + "] with index[" + bIndex + "] is selected.");


                    /*获取barcode对应的产品信息*/
                    LTS.Product p = new LTS.Product();
                    p = DAT.DataAccess.GetProduct().Where(f => f.BarcodeID == barID).FirstOrDefault();
                    if (p == null)
                    {
                        Log.WriteLog(LogType.Warning, "there is not product band with barcode[" + barID + "]");

                        panel1.Controls.Clear();

                        lBarcodeMsg.Parent = panel1;
                        lBarcodeMsg.Dock   = DockStyle.Fill;
                        lBarcodeMsg.BringToFront();
                        lBarcodeMsg.Visible = true;
                        return;
                    }

                    Log.WriteLog(LogType.Trace, "success get product[" + p.ProductID + "] witch bind with barcode[" + barID + "]");
                    string pBarcode = cbBarcode.Text;

                    /*获得产品的厂家id和类型id*/
                    string brand = DAT.DataAccess.GetBrand().Where(o => o.BrandID == p.BrandID).FirstOrDefault().BrandName;
                    Log.WriteLog(LogType.Trace, "success get brand[" + p.BrandID + "] witch named[" + brand + "]");

                    string cat = DAT.DataAccess.GetCategory().Where(o => o.CategoryID == p.CategoryID).FirstOrDefault().CategoryName;
                    Log.WriteLog(LogType.Trace, "success get category[" + p.CategoryID + "] witch named[" + cat + "]");


                    /*显示barcode对应的产品详细信息*/
                    try
                    {
                        Log.WriteLog(LogType.Trace, "goto show the barcode[" + barID + "] beyond to product[" + p.ProductID + "] in brand[" + p.BrandID + "] category[" + p.CategoryID + "] detail info");

                        panel1.Controls.Clear();
                        Control find = new ShowProductDetails(pBarcode, p.ProductName, p.ProductDescription, brand, cat);
                        find.Parent = panel1;
                        find.Dock   = DockStyle.Fill;
                        find.BringToFront();
                    }
                    catch (Exception ex)
                    {
                        Log.WriteLog(LogType.Trace, "error to show barcode[" + barID + "] detail info");
                        throw ex;
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteLog(LogType.Trace, "error to get barcode detail info");
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
示例#5
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!");
            }
        }
示例#6
0
        //Devon
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                lblSelect.Visible = false;
                label16.Visible   = false;
                label4.Visible    = false;
                label7.Visible    = false;

                if (current.itemID != 0)
                {
                    if (textBox2.Text == oldEPC)
                    {
                        int      itemID  = Int32.Parse(label5.Text);
                        LTS.Item olditem = DAT.DataAccess.GetItem().Where(d => d.ItemID == itemID).FirstOrDefault();

                        bool status = olditem.ItemStatus;

                        int sIndex = comboBoxStore.SelectedIndex;
                        int bIndex = comboBox1.SelectedIndex;
                        if (sIndex == -1 || bIndex == -1)
                        {
                            label7.Visible = true;
                        }
                        else
                        {
                            label7.Visible = false;
                            int storeID = listS[sIndex].StoreID;
                            int barID   = listBar[bIndex].BarcodeID;

                            LTS.Product p = new LTS.Product();
                            p = DAT.DataAccess.GetProduct().Where(f => f.BarcodeID == barID).FirstOrDefault();
                            int      productID;
                            LTS.Item checkTag = DAT.DataAccess.GetItem().Where(b => b.TagEPC == textBox2.Text).FirstOrDefault();

                            if (p != null)
                            {
                                try
                                {
                                    if (textBox2.Text == "")
                                    {
                                        label4.Text    = "Please enter the RFID Tag!";
                                        label4.Visible = true;
                                    }
                                    else
                                    {
                                        label4.Visible = false;
                                        productID      = p.ProductID;
                                        LTS.Item newitem = new LTS.Item();
                                        newitem.ItemID     = itemID;
                                        newitem.ItemStatus = status;
                                        newitem.ProductID  = productID;
                                        newitem.TagEPC     = textBox2.Text;
                                        newitem.StoreID    = storeID;

                                        bool check = DAT.DataAccess.UpdateItem(newitem);
                                        if (check)
                                        {
                                            MessageBox.Show("Item has been updated!");
                                            ((Main)this.Parent.Parent).ChangeView <Pages.Items.Items>();
                                        }
                                        else
                                        {
                                            MessageBox.Show("Item has not been updated!");
                                        }
                                    }
                                }
                                catch
                                {
                                    MessageBox.Show("Item has not been updated!");
                                }
                            }
                        }
                    }
                    else
                    {
                        LTS.Item ite = DAT.DataAccess.GetItem().Where(i => i.TagEPC == textBox2.Text).FirstOrDefault();
                        if (ite == null)
                        {
                            int      itemID  = Int32.Parse(label5.Text);
                            LTS.Item olditem = DAT.DataAccess.GetItem().Where(d => d.ItemID == itemID).FirstOrDefault();

                            bool status = olditem.ItemStatus;

                            int sIndex = comboBoxStore.SelectedIndex;
                            int bIndex = comboBox1.SelectedIndex;
                            if (sIndex == -1 || bIndex == -1)
                            {
                                label7.Visible = true;
                            }
                            else
                            {
                                label7.Visible = false;
                                int storeID = listS[sIndex].StoreID;
                                int barID   = listBar[bIndex].BarcodeID;

                                LTS.Product p = new LTS.Product();
                                p = DAT.DataAccess.GetProduct().Where(f => f.BarcodeID == barID).FirstOrDefault();
                                int      productID;
                                LTS.Item checkTag = DAT.DataAccess.GetItem().Where(b => b.TagEPC == textBox2.Text).FirstOrDefault();

                                if (p != null)
                                {
                                    try
                                    {
                                        if (textBox2.Text == "")
                                        {
                                            label4.Text    = "Please enter the RFID Tag!";
                                            label4.Visible = true;
                                        }
                                        else
                                        {
                                            label4.Visible = false;
                                            productID      = p.ProductID;
                                            LTS.Item newitem = new LTS.Item();
                                            newitem.ItemID     = itemID;
                                            newitem.ItemStatus = status;
                                            newitem.ProductID  = productID;
                                            newitem.TagEPC     = textBox2.Text;
                                            newitem.StoreID    = storeID;

                                            bool check = DAT.DataAccess.UpdateItem(newitem);
                                            if (check)
                                            {
                                                MessageBox.Show("Item has been updated!");
                                                ((Main)this.Parent.Parent).ChangeView <Pages.Items.Items>();
                                            }
                                            else
                                            {
                                                MessageBox.Show("Item has not been updated!");
                                            }
                                        }
                                    }
                                    catch
                                    {
                                        MessageBox.Show("Item has not been updated!");
                                    }
                                }
                            }
                        }
                        else
                        {
                            label4.Visible = true;
                            label4.Text    = "TAG alreasy exists! Please enter a different one.";
                        }
                    }
                }
                else
                {
                    lblSelect.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
        //Devon
        private void btnlogin_Click(object sender, EventArgs e)
        {
            try
            {
                LTS.Item i = new LTS.Item();

                int storeIndex = comboBoxStore.SelectedIndex;
                if (storeIndex == -1)
                {
                    label45.Visible = true;
                }
                else
                {
                    int storeID = listS[storeIndex].StoreID;
                    i.StoreID       = storeID;
                    label45.Visible = false;
                }

                int barcodeIndex = comboBox1.SelectedIndex;
                if (barcodeIndex == -1)
                {
                    label16.Visible = true;
                }
                else
                {
                    int         barcodeID = listBar[barcodeIndex].BarcodeID;
                    LTS.Product p         = DAT.DataAccess.GetProduct().Where(a => a.BarcodeID == barcodeID).FirstOrDefault();
                    LTS.Item    checkTag  = DAT.DataAccess.GetItem().Where(b => b.TagEPC == textBox2.Text).FirstOrDefault();

                    label6.Visible = false;

                    if (p != null && checkTag == null)
                    {
                        if (textBox2.Text != "")
                        {
                            i.TagEPC       = textBox2.Text;
                            label6.Visible = false;
                        }
                        else
                        {
                            label6.Visible = true;
                        }

                        i.ProductID     = p.ProductID;
                        i.ItemStatus    = true;
                        label16.Visible = false;

                        int returnedID = DAT.DataAccess.AddItem(i);
                        if (returnedID == -1)
                        {
                            MessageBox.Show("Item was not added to the database!");
                        }
                        else
                        {
                            MessageBox.Show("Item was succesfully added to the database");
                            ((Main)this.Parent.Parent).ChangeView <Pages.Items.Items>();
                        }
                    }
                    else
                    {
                        label6.Visible = true;
                        label6.Text    = "TAG alreasy exists! Please enter a different one.";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
示例#8
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();
            }
        }
示例#9
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();
            }
        }