Exemplo n.º 1
0
        private void tsbDelete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

            if (MessageBox.Show("Delete the selected customer/vendor will also delete its related BOM/Offer", "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }

            DataGridViewRow dgvr = dataGridView1.SelectedRows[0];
            int             custVenIdSelected = Convert.ToInt32(dgvr.Cells["Id"].Value);

            using (BomOfferEntities entity = new BomOfferEntities())
            {
                var bomOfferList = entity.publicbomoffer.Where(bomOffer => bomOffer.BomCustVendId == custVenIdSelected);
                foreach (var bomOffer in bomOfferList)
                {
                    entity.DeleteObject(bomOffer);
                }

                entity.DeleteObject(entity.publiccustven.Where(cv => cv.custVenId == custVenIdSelected).First());

                entity.SaveChanges();
            }

            BomOfferCustVendor_Load(this, null);
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (tbCustVenName.Text.Length == 0)
            {
                MessageBox.Show("Please input the Customer/Vendor Name");
            }
            var publicCustVen = new publiccustven
            {
                custVenName=tbCustVenName.Text.Trim(),
                custVendorType=(sbyte)(bomOfferType),
                contact=tbContact.Text.Trim(),
                tel=tbTel.Text.Trim(),
                email=tbEmail.Text.Trim(),
                userID=(short)UserInfo.UserId,
                enterDay=DateTime.Now
            };
            using (BomOfferEntities entity = new BomOfferEntities())
            {
                entity.publiccustven.AddObject(publicCustVen);
                entity.SaveChanges();
            }

            this.DialogResult = DialogResult.OK;

            this.Close();
        }
Exemplo n.º 3
0
        private void tsbDeleteItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }
            if (MessageBox.Show("Delete the selected item?", "Delete", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            DataGridViewSelectedRowCollection dgvrrc = dataGridView1.SelectedRows;
            int bomOfferId;

            using (BomOfferEntities entity = new BomOfferEntities())
            {
                foreach (DataGridViewRow dgvr in dgvrrc)
                {
                    bomOfferId = Convert.ToInt32(dgvr.Cells["Id"].Value);
                    var bomOfferItem = entity.publicbomoffer.First(item => item.bomOfferId == bomOfferId);
                    entity.publicbomoffer.DeleteObject(bomOfferItem);
                }
                entity.SaveChanges();
            }
            if (listAll)
            {
                tsbListAll_Click(this, null);
            }
            else
            {
                tsbSearch_Click(this, null);
            }
        }
Exemplo n.º 4
0
        private void tsbSearch_Click(object sender, EventArgs e)
        {
            if ((tscbFilterBy.Text.Trim().Length == 0) || (tstbFilterString.Text.Trim().Length == 0))
            {
                return;
            }

            if ((tscbFilterBy.SelectedIndex == 0) && (tstbFilterString.Text.Trim().Length != 0))
            {
                using (BomOfferEntities entity = new BomOfferEntities())
                {
                    var bomOfferList = from bomOffer in entity.publicbomoffer
                                       join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                       where custVen.custVendorType == (isOffer ? 1 : 0) && (custVen.custVenName.Contains(tstbFilterString.Text.Trim()))
                                       select new
                    {
                        Id      = bomOffer.BomCustVendId,
                        Company = custVen.custVenName,
                        MFG     = bomOffer.mfg,
                        MPN     = bomOffer.mpn,
                        Qty     = bomOffer.qty,
                        Price   = bomOffer.price,
                        Cpn     = bomOffer.cpn
                    };

                    this.dataGridView1.DataSource = bomOfferList;
                }
            }
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (tbCustVenName.Text.Length == 0)
            {
                MessageBox.Show("Please input the Customer/Vendor Name");
            }
            var publicCustVen = new publiccustven
            {
                custVenName    = tbCustVenName.Text.Trim(),
                custVendorType = (sbyte)(isOffer?1:0),
                contact        = tbContact.Text.Trim(),
                tel            = tbTel.Text.Trim(),
                email          = tbEmail.Text.Trim(),
                userID         = (short)UserInfo.UserId,
                enterDay       = DateTime.Now
            };

            using (BomOfferEntities entity = new BomOfferEntities())
            {
                entity.publiccustven.AddObject(publicCustVen);
                entity.SaveChanges();
            }

            this.DialogResult = DialogResult.OK;

            this.Close();
        }
Exemplo n.º 6
0
        private void BomOfferList_Load(object sender, EventArgs e)
        {
            if (isOffer)
                this.Text = "Offers List";
            else
                this.Text = "BOMs List";

            if (listbyCustVen)
            {
                tscbFilterBy.Enabled = false;
                tstbFilterString.Enabled = false;
                tsbSearch.Enabled = false;
                tsbCancel.Enabled = false;
            }

            using (BomOfferEntities entity = new BomOfferEntities())
            {
                if (listbyCustVen)
                {
                    var bomOfferList = from bomOffer in entity.publicbomoffer
                                       join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                       where custVen.custVendorType == (isOffer ? 1 : 0) && custVen.custVenId==this.custVenId

                                       select new
                                       {
                                           Id = bomOffer.BomCustVendId,
                                           MFG = bomOffer.mfg,
                                           MPN = bomOffer.mpn,
                                           Qty = bomOffer.qty,
                                           Price = bomOffer.price,
                                           Cpn = bomOffer.cpn
                                       };

                    this.dataGridView1.DataSource = bomOfferList;

                }

                else
                {

                    var bomOfferList = from bomOffer in entity.publicbomoffer
                                       join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                       where custVen.custVendorType == (isOffer ? 1 : 0)
                                       select new
                                       {
                                           Id=bomOffer.BomCustVendId,
                                           Company = custVen.custVenName,
                                           MFG = bomOffer.mfg,
                                           MPN = bomOffer.mpn,
                                           Qty = bomOffer.qty,
                                           Price = bomOffer.price,
                                           Cpn = bomOffer.cpn
                                       };

                    this.dataGridView1.DataSource = bomOfferList;
                }

            }
        }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!ItemsCheck.CheckTextBoxEmpty(tbMfg))
            {
                MessageBox.Show("Please input the MFG");
                return;
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbMpn))
            {
                MessageBox.Show("Please input the MPN");
                return;
            }

            if (!ItemsCheck.CheckIntNumber(tbQty))
            {
                MessageBox.Show("The QTY should be an integer value");
                tbQty.Focus();
                return;
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbPrice))
            {
                MessageBox.Show("Please input the Price");
                return;
            }
            else
            {
                if (!ItemsCheck.CheckFloatNumber(tbPrice))
                {
                    MessageBox.Show("The Price should be a float number");
                    tbPrice.Focus();
                    return;
                }
            }



            var publicBomOff = new publicbomoffer
            {
                mfg           = tbMfg.Text.Trim(),
                mpn           = tbMpn.Text.Trim(),
                qty           = int.Parse(tbQty.Text.Trim()),
                price         = float.Parse(tbPrice.Text.Trim()),
                cpn           = tbCpn.Text.Trim(),
                userID        = (short)UserInfo.UserId,
                BomCustVendId = this.custVenId,
                enerDay       = DateTime.Now
            };

            using (BomOfferEntities entity = new BomOfferEntities())
            {
                entity.publicbomoffer.AddObject(publicBomOff);
                entity.SaveChanges();
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 8
0
 private void FillTheDataGrid()
 {
     this.dataGridView1.Rows.Clear();
     using (BomOfferEntities entity = new BomOfferEntities())
     {
         if (tscbSearchBy.SelectedIndex < 0 || tstbFilterString.Text.Trim().Length == 0)
         {
             var bomOfferList = from bomOffer in entity.publiccustven
                                join myaccount in entity.account on bomOffer.userID equals myaccount.id
                                where bomOffer.custVendorType == (int)bomOfferType
                                orderby bomOffer.enterDay descending
                                select new
             {
                 Id       = bomOffer.custVenId,
                 Name     = bomOffer.custVenName,
                 Contact  = bomOffer.contact,
                 Tel      = bomOffer.tel,
                 Email    = bomOffer.email,
                 User     = myaccount.accountName,
                 EnterDay = bomOffer.enterDay
             };
             foreach (var bomOffer in bomOfferList)
             {
                 dataGridView1.Rows.Add(bomOffer.Id, bomOffer.Name, bomOffer.Contact, bomOffer.Tel, bomOffer.Email, bomOffer.User, bomOffer.EnterDay);
             }
         }
         else
         {
             var bomOfferList = from bomOffer in entity.publiccustven
                                join myaccount in entity.account on bomOffer.userID equals myaccount.id
                                where bomOffer.custVendorType == ((int)bomOfferType) && bomOffer.custVenName.Contains(tstbFilterString.Text.Trim())
                                orderby bomOffer.enterDay descending
                                select new
             {
                 Id       = bomOffer.custVenId,
                 Name     = bomOffer.custVenName,
                 Contact  = bomOffer.contact,
                 Tel      = bomOffer.tel,
                 Email    = bomOffer.email,
                 User     = myaccount.accountName,
                 EnterDay = bomOffer.enterDay
             };
             foreach (var bomOffer in bomOfferList)
             {
                 dataGridView1.Rows.Add(bomOffer.Id, bomOffer.Name, bomOffer.Contact, bomOffer.Tel, bomOffer.Email, bomOffer.User, bomOffer.EnterDay);
             }
         }
     }
 }
Exemplo n.º 9
0
        private void BomOfferCustVendor_Load(object sender, EventArgs e)
        {
            using(BomOfferEntities entity=new BomOfferEntities())
            {

                if(isOffer)
                {
             var bomOfferList=from bomOffer in entity.publiccustven join myaccount in entity.account on bomOffer.userID equals myaccount.id
                                      where bomOffer.custVendorType==1
                                      select new
                                       {
                                          Id=bomOffer.custVenId,
                                          VendorName=bomOffer.custVenName,
                                          Contact=bomOffer.contact,
                                          Tel=bomOffer.tel,
                                          Email=bomOffer.email,
                                          Sale=myaccount.accountName,
                                          EnterDay=bomOffer.enterDay
                                       };
                  this.dataGridView1.DataSource=bomOfferList;
                }
                else
                {
                 var bomOfferList=from bomOffer in entity.publiccustven join myaccount in entity.account on bomOffer.userID equals myaccount.id
                                      where bomOffer.custVendorType==0
                                      select new
                                       {
                                          Id=bomOffer.custVenId,
                                          CustomerName=bomOffer.custVenName,
                                          Contact=bomOffer.contact,
                                          Tel=bomOffer.tel,
                                          Email=bomOffer.email,
                                          Buyer=myaccount.accountName,
                                          EnterDay=bomOffer.enterDay
                                       };
                 this.dataGridView1.DataSource = bomOfferList;

                }

            }
        }
Exemplo n.º 10
0
 private void BomOfferCustVendor_Load(object sender, EventArgs e)
 {
     using (BomOfferEntities entity = new BomOfferEntities())
     {
         if (isOffer)
         {
             var bomOfferList = from bomOffer in entity.publiccustven join myaccount in entity.account on bomOffer.userID equals myaccount.id
                                where bomOffer.custVendorType == 1
                                select new
             {
                 Id         = bomOffer.custVenId,
                 VendorName = bomOffer.custVenName,
                 Contact    = bomOffer.contact,
                 Tel        = bomOffer.tel,
                 Email      = bomOffer.email,
                 Sale       = myaccount.accountName,
                 EnterDay   = bomOffer.enterDay
             };
             this.dataGridView1.DataSource = bomOfferList;
         }
         else
         {
             var bomOfferList = from bomOffer in entity.publiccustven join myaccount in entity.account on bomOffer.userID equals myaccount.id
                                where bomOffer.custVendorType == 0
                                select new
             {
                 Id           = bomOffer.custVenId,
                 CustomerName = bomOffer.custVenName,
                 Contact      = bomOffer.contact,
                 Tel          = bomOffer.tel,
                 Email        = bomOffer.email,
                 Buyer        = myaccount.accountName,
                 EnterDay     = bomOffer.enterDay
             };
             this.dataGridView1.DataSource = bomOfferList;
         }
     }
 }
Exemplo n.º 11
0
        private void tsbDeleteItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }
            if (MessageBox.Show("Delete the selected item?", "Delete", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            DataGridViewRow dgvr       = dataGridView1.SelectedRows[0];
            int             bomOfferId = Convert.ToInt32(dgvr.Cells["Id"].Value);


            using (BomOfferEntities entity = new BomOfferEntities())
            {
                var bomOfferItem = entity.publicbomoffer.First(item => item.BomCustVendId == bomOfferId);
                entity.DeleteObject(bomOfferItem);
                entity.SaveChanges();
            }
            BomOfferList_Load(this, null);
        }
Exemplo n.º 12
0
        private void tsbSearch_Click(object sender, EventArgs e)
        {
            listAll = false;
            if ((tscbFilterBy.Text.Trim().Length == 0) || (tstbFilterString.Text.Trim().Length == 0))
            {
                return;
            }

            if (((tscbFilterBy.Text.Trim() == "Vendor Name") || (tscbFilterBy.Text.Trim() == "Customer Name") || (tscbFilterBy.Text.Trim() == "Company Name")) &&
                (tstbFilterString.Text.Trim().Length != 0))
            {
                if (listbyCustVen)
                {
                    return;
                }
                using (BomOfferEntities entity = new BomOfferEntities())
                {
                    this.dataGridView1.DataSource = null;
                    if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                    {
                        var bomOfferList = from bomOffer in entity.publicbomoffer
                                           join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                           join a in entity.account on bomOffer.userID equals a.id
                                           where custVen.custVendorType == (int)this.bomOfferType && (custVen.custVenName.Contains(tstbFilterString.Text.Trim()))
                                           orderby bomOffer.bomOfferId descending
                                           select new
                        {
                            Id       = bomOffer.bomOfferId,
                            Company  = custVen.custVenName,
                            MFG      = bomOffer.mfg,
                            MPN      = bomOffer.mpn,
                            Qty      = bomOffer.qty,
                            Price    = bomOffer.price,
                            CPN      = bomOffer.cpn,
                            Owner    = a.accountName,
                            Enterday = bomOffer.enerDay
                        };
                        this.dataGridView1.DataSource         = bomOfferList;
                        this.dataGridView1.Columns[0].Visible = false;
                    }
                    else
                    {
                        var bomOfferList = from bomOffer in entity.publicbomoffer
                                           join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                           join a in entity.account on bomOffer.userID equals a.id
                                           where custVen.custVendorType == (int)this.bomOfferType && (custVen.custVenName.Contains(tstbFilterString.Text.Trim()))
                                           orderby bomOffer.bomOfferId descending
                                           select new
                        {
                            Id       = bomOffer.bomOfferId,
                            Company  = "OEM",
                            MFG      = bomOffer.mfg,
                            MPN      = bomOffer.mpn,
                            Qty      = bomOffer.qty,
                            Price    = bomOffer.price,
                            CPN      = "OEM",
                            Owner    = a.accountName,
                            Enterday = bomOffer.enerDay
                        };
                        this.dataGridView1.DataSource         = bomOfferList;
                        this.dataGridView1.Columns[0].Visible = false;
                    }
                }
            }
            else if ((tscbFilterBy.Text.Trim() == "MPN") && (tstbFilterString.Text.Trim().Length != 0))
            {
                using (BomOfferEntities entity = new BomOfferEntities())
                {
                    if (listbyCustVen)
                    {
                        this.dataGridView1.DataSource = null;
                        if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && (bomOffer.mpn.Contains(tstbFilterString.Text.Trim()) &&
                                                                                                          (custVen.custVenId == this.custVenId))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                            {
                                Id       = bomOffer.bomOfferId,
                                Company  = custVen.custVenName,
                                MFG      = bomOffer.mfg,
                                MPN      = bomOffer.mpn,
                                Qty      = bomOffer.qty,
                                Price    = bomOffer.price,
                                CPN      = bomOffer.cpn,
                                Owner    = a.accountName,
                                Enterday = bomOffer.enerDay
                            };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                        else
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && (bomOffer.mpn.Contains(tstbFilterString.Text.Trim()) &&
                                                                                                          (custVen.custVenId == this.custVenId))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                            {
                                Id       = bomOffer.bomOfferId,
                                Company  = "OEM",
                                MFG      = bomOffer.mfg,
                                MPN      = bomOffer.mpn,
                                Qty      = bomOffer.qty,
                                Price    = bomOffer.price,
                                CPN      = "OEM",
                                Owner    = a.accountName,
                                Enterday = bomOffer.enerDay
                            };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                    }
                    else
                    {
                        this.dataGridView1.DataSource = null;
                        if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && (bomOffer.mpn.Contains(tstbFilterString.Text.Trim()))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                            {
                                Id       = bomOffer.bomOfferId,
                                Company  = custVen.custVenName,
                                MFG      = bomOffer.mfg,
                                MPN      = bomOffer.mpn,
                                Qty      = bomOffer.qty,
                                Price    = bomOffer.price,
                                CPN      = bomOffer.cpn,
                                Owner    = a.accountName,
                                Enterday = bomOffer.enerDay
                            };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                        else
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && (bomOffer.mpn.Contains(tstbFilterString.Text.Trim()))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                            {
                                Id       = bomOffer.bomOfferId,
                                Company  = "OEM",
                                MFG      = bomOffer.mfg,
                                MPN      = bomOffer.mpn,
                                Qty      = bomOffer.qty,
                                Price    = bomOffer.price,
                                CPN      = "OEM",
                                Owner    = a.accountName,
                                Enterday = bomOffer.enerDay
                            };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                    }
                }
            }

            else if ((tscbFilterBy.Text.Trim() == "Date") && (tstbFilterString.Text.Trim().Length != 0))
            {
                string[] date = AmbleClient.RfqGui.RfqManager.RfqMgr.GetStartDateAndEndDate(tstbFilterString.Text.Trim());
                if (string.IsNullOrWhiteSpace(date[0]) || string.IsNullOrWhiteSpace(date[1]))
                {
                    MessageBox.Show("Format error in the Filter String");
                    return;
                }
                DateTime startDate, endDate;

                try{
                    startDate = DateTime.Parse(date[0]);
                    endDate   = DateTime.Parse(date[1]);
                }
                catch
                {
                    MessageBox.Show("Format error in the Filter String");
                    return;
                }



                using (BomOfferEntities entity = new BomOfferEntities())
                {
                    if (listbyCustVen)
                    {
                        this.dataGridView1.DataSource = null;
                        if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where (custVen.custVendorType == (int)this.bomOfferType && ((bomOffer.enerDay.HasValue) && (bomOffer.enerDay.Value > startDate) && (bomOffer.enerDay.Value < endDate)) &&
                                                      (custVen.custVenId == this.custVenId))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                            {
                                Id       = bomOffer.bomOfferId,
                                Company  = custVen.custVenName,
                                MFG      = bomOffer.mfg,
                                MPN      = bomOffer.mpn,
                                Qty      = bomOffer.qty,
                                Price    = bomOffer.price,
                                CPN      = bomOffer.cpn,
                                Owner    = a.accountName,
                                Enterday = bomOffer.enerDay
                            };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                        else
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where (custVen.custVendorType == (int)this.bomOfferType && ((bomOffer.enerDay.HasValue) && (bomOffer.enerDay.Value > startDate) && (bomOffer.enerDay.Value < endDate)) &&
                                                      (custVen.custVenId == this.custVenId))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                            {
                                Id       = bomOffer.bomOfferId,
                                Company  = "OEM",
                                MFG      = bomOffer.mfg,
                                MPN      = bomOffer.mpn,
                                Qty      = bomOffer.qty,
                                Price    = bomOffer.price,
                                CPN      = "OEM",
                                Owner    = a.accountName,
                                Enterday = bomOffer.enerDay
                            };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                    }
                    else
                    {
                        this.dataGridView1.DataSource = null;
                        if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && ((bomOffer.enerDay.HasValue) && (bomOffer.enerDay.Value > startDate) && (bomOffer.enerDay.Value < endDate))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                            {
                                Id       = bomOffer.bomOfferId,
                                Company  = custVen.custVenName,
                                MFG      = bomOffer.mfg,
                                MPN      = bomOffer.mpn,
                                Qty      = bomOffer.qty,
                                Price    = bomOffer.price,
                                CPN      = bomOffer.cpn,
                                Owner    = a.accountName,
                                Enterday = bomOffer.enerDay
                            };
                            this.dataGridView1.DataSource         = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                        else
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && ((bomOffer.enerDay.HasValue) && (bomOffer.enerDay.Value > startDate) && (bomOffer.enerDay.Value < endDate))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                            {
                                Id       = bomOffer.bomOfferId,
                                Company  = "OEM",
                                MFG      = bomOffer.mfg,
                                MPN      = bomOffer.mpn,
                                Qty      = bomOffer.qty,
                                Price    = bomOffer.price,
                                CPN      = "OEM",
                                Owner    = a.accountName,
                                Enterday = bomOffer.enerDay
                            };
                            this.dataGridView1.DataSource         = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                    }
                }
            }

            else
            {
            }
        }
Exemplo n.º 13
0
        private void tsbSearch_Click(object sender, EventArgs e)
        {
            if ((tscbFilterBy.Text.Trim().Length == 0)|| (tstbFilterString.Text.Trim().Length == 0))
                return;

            if ((tscbFilterBy.SelectedIndex == 0) && (tstbFilterString.Text.Trim().Length != 0))
            {
                using (BomOfferEntities entity = new BomOfferEntities())
                {
                    var bomOfferList = from bomOffer in entity.publicbomoffer
                                       join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                       where custVen.custVendorType == (isOffer ? 1 : 0) &&(custVen.custVenName.Contains(tstbFilterString.Text.Trim()))
                                       select new
                                       {
                                           Id = bomOffer.BomCustVendId,
                                           Company = custVen.custVenName,
                                           MFG = bomOffer.mfg,
                                           MPN = bomOffer.mpn,
                                           Qty = bomOffer.qty,
                                           Price = bomOffer.price,
                                           Cpn = bomOffer.cpn
                                       };

                    this.dataGridView1.DataSource = bomOfferList;

                }

            }
        }
Exemplo n.º 14
0
        private void tsbDeleteItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0) return;
            if (MessageBox.Show("Delete the selected item?", "Delete", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

               DataGridViewRow dgvr = dataGridView1.SelectedRows[0];
               int bomOfferId = Convert.ToInt32(dgvr.Cells["Id"].Value);

            using (BomOfferEntities entity = new BomOfferEntities())
            {
                var bomOfferItem = entity.publicbomoffer.First(item => item.BomCustVendId == bomOfferId);
                entity.DeleteObject(bomOfferItem);
                entity.SaveChanges();
            }
            BomOfferList_Load(this,null);
        }
Exemplo n.º 15
0
        private void tsbListAll_Click(object sender, EventArgs e)
        {
            listAll = true;
            dataGridView1.DataSource = null;
            using (BomOfferEntities entity = new BomOfferEntities())
            {
                if (listbyCustVen)
                {
                    if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                    {
                        var bomOfferList = from bomOffer in entity.publicbomoffer
                                           join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                           join a in entity.account on bomOffer.userID equals a.id
                                           where custVen.custVendorType == (int)this.bomOfferType && custVen.custVenId == this.custVenId
                                           orderby bomOffer.bomOfferId descending
                                           select new
                        {
                            Id       = bomOffer.bomOfferId,
                            Company  = custVen.custVenName,
                            MFG      = bomOffer.mfg,
                            MPN      = bomOffer.mpn,
                            Qty      = bomOffer.qty,
                            Price    = bomOffer.price,
                            Owner    = a.accountName,
                            CPN      = bomOffer.cpn,
                            Enterday = bomOffer.enerDay
                        };
                        dataGridView1.DataSource = bomOfferList;
                        this.dataGridView1.Columns[0].Visible = false;
                    }
                    else
                    {
                        var bomOfferList = from bomOffer in entity.publicbomoffer
                                           join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                           join a in entity.account on bomOffer.userID equals a.id
                                           where custVen.custVendorType == (int)this.bomOfferType && custVen.custVenId == this.custVenId
                                           orderby bomOffer.bomOfferId descending
                                           select new
                        {
                            Id       = bomOffer.bomOfferId,
                            Company  = "OEM",
                            MFG      = bomOffer.mfg,
                            MPN      = bomOffer.mpn,
                            Qty      = bomOffer.qty,
                            Price    = bomOffer.price,
                            Owner    = a.accountName,
                            CPN      = "OEM",
                            Enterday = bomOffer.enerDay
                        };
                        dataGridView1.DataSource = bomOfferList;
                        this.dataGridView1.Columns[0].Visible = false;
                    }
                }

                else
                {
                    if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                    {
                        var bomOfferList = from bomOffer in entity.publicbomoffer
                                           join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                           join a in entity.account on bomOffer.userID equals a.id
                                           where custVen.custVendorType == (int)this.bomOfferType
                                           orderby bomOffer.bomOfferId descending
                                           select new
                        {
                            Id       = bomOffer.bomOfferId,
                            Company  = custVen.custVenName,
                            MFG      = bomOffer.mfg,
                            MPN      = bomOffer.mpn,
                            Qty      = bomOffer.qty,
                            Price    = bomOffer.price,
                            CPN      = bomOffer.cpn,
                            Ower     = a.accountName,
                            Enterday = bomOffer.enerDay
                        };

                        dataGridView1.DataSource = bomOfferList;
                        this.dataGridView1.Columns[0].Visible = false;
                    }
                    else
                    {
                        var bomOfferList = from bomOffer in entity.publicbomoffer
                                           join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                           join a in entity.account on bomOffer.userID equals a.id
                                           where custVen.custVendorType == (int)this.bomOfferType
                                           orderby bomOffer.bomOfferId descending
                                           select new
                        {
                            Id       = bomOffer.bomOfferId,
                            Company  = "OEM",
                            MFG      = bomOffer.mfg,
                            MPN      = bomOffer.mpn,
                            Qty      = bomOffer.qty,
                            Price    = bomOffer.price,
                            CPN      = "OEM",
                            Owner    = a.accountName,
                            Enterday = bomOffer.enerDay
                        };


                        //AllAccountInfo.GetNameAccordingToId
                        dataGridView1.DataSource = bomOfferList;
                        this.dataGridView1.Columns[0].Visible = false;
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void tsbExportFromExcel_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0) return;

            DataGridViewRow dgvr = dataGridView1.SelectedRows[0];
            int custVenId = Convert.ToInt32(dgvr.Cells["Id"].Value);

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Excel文件(*.xls)|*.xls";
            ofd.RestoreDirectory = true;
            ofd.Multiselect = false;

            if (DialogResult.OK == ofd.ShowDialog())
            {
                DataTable dt = ExcelHelper.ExcelHelper.Import(ofd.FileName);
                if (dt.Rows.Count == 0)
                    return;

                bool hasCpn=false,hasMpn=false,hasMfg=false,hasQty=false,hasPrice=false;
                int cpnColumn = -1, mpnColumn = -1, mfgColumn = -1, qtyColumn = -1, priceColumn = -1;
                foreach (DataColumn dc in dt.Columns)
                {
                    if (dc.ColumnName.Trim().ToUpper() == "MPN")
                    {
                        hasMpn = true;
                        mpnColumn=dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "CPN")
                    {
                        hasCpn = true;
                        cpnColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "MFG")
                    {
                        hasMfg = true;
                        mfgColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "QTY")
                    {
                        hasQty = true;
                        qtyColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "PRICE")
                    {
                        hasPrice = true;
                        priceColumn = dt.Columns.IndexOf(dc);
                    }
                }
                if (false == (hasPrice && hasMpn && hasCpn && hasMfg && hasQty))
                {
                    MessageBox.Show("Please check the xls File Column.(CPN,MPN,MFG,QTY,PRICE)");
                    return;
                }

              //  List<publicbomoffer> publicbomOfferList = new List<publicbomoffer>();
                 using (BomOfferEntities entity = new BomOfferEntities())
                {   int i=1;
                    foreach (DataRow dr in dt.Rows)
                    {

                        //Qty omit the ","

                        string qtyString = dr[qtyColumn].ToString();
                        qtyString = qtyString.Replace(",",string.Empty);

                        if (!string.IsNullOrWhiteSpace(qtyString) && (!ItemsCheck.CheckIntNumber(qtyString)))
                        {

                            MessageBox.Show("The Qty value is not correct in row " + i.ToString());
                            return;
                        }
                        if (!string.IsNullOrWhiteSpace(dr[priceColumn].ToString()) && (!ItemsCheck.CheckFloatNumber(dr[priceColumn])))
                        {

                            MessageBox.Show("The Price value is not correct in row " + i.ToString());
                            return;
                        }

                        int? qtyLocal;
                        float? priceLocal;

                        if (string.IsNullOrWhiteSpace(qtyString))
                        {
                            qtyLocal = null;
                        }
                        else
                        {
                            qtyLocal = Convert.ToInt32(qtyString);
                        }

                        if (string.IsNullOrWhiteSpace(dr[priceColumn].ToString()))
                        {
                            priceLocal = null;
                        }
                        else
                        {
                            priceLocal = Convert.ToSingle(dr[priceColumn]);
                        }

                        entity.publicbomoffer.AddObject(
                        new publicbomoffer
                         {
                       mfg = dr[mfgColumn].ToString(),
                       mpn = dr[mpnColumn].ToString(),
                       qty =qtyLocal,
                       price = priceLocal,
                       cpn = dr[cpnColumn].ToString(),
                       userID = (short)UserInfo.UserId,
                       BomCustVendId = custVenId,
                       enerDay = DateTime.Now
                         }

                       );
                     i++;
                    }
                    entity.SaveChanges();
                }

                 MessageBox.Show("Import file " + ofd.FileName + " successfully.");
            }
        }
Exemplo n.º 17
0
        private void tsbSearch_Click(object sender, EventArgs e)
        {
            listAll = false;
            if ((tscbFilterBy.Text.Trim().Length == 0)|| (tstbFilterString.Text.Trim().Length == 0))
                return;

            if (((tscbFilterBy.Text.Trim() == "Vendor Name") || (tscbFilterBy.Text.Trim() == "Customer Name")||(tscbFilterBy.Text.Trim()=="Company Name"))
                && (tstbFilterString.Text.Trim().Length != 0))
            {
                if (listbyCustVen)
                {
                    return;
                }
                using (BomOfferEntities entity = new BomOfferEntities())
                {
                    this.dataGridView1.DataSource = null;
                    if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                    {
                        var bomOfferList = from bomOffer in entity.publicbomoffer
                                           join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                           join a in entity.account on bomOffer.userID equals a.id
                                           where custVen.custVendorType == (int)this.bomOfferType && (custVen.custVenName.Contains(tstbFilterString.Text.Trim()))
                                           orderby bomOffer.bomOfferId descending
                                           select new
                                           {
                                               Id = bomOffer.bomOfferId,
                                               Company = custVen.custVenName,
                                               MFG = bomOffer.mfg,
                                               MPN = bomOffer.mpn,
                                               Qty = bomOffer.qty,
                                               Price = bomOffer.price,
                                               CPN = bomOffer.cpn,
                                               Owner = a.accountName,
                                               Enterday = bomOffer.enerDay
                                           };
                        this.dataGridView1.DataSource = bomOfferList;
                        this.dataGridView1.Columns[0].Visible = false;
                    }
                    else
                    {
                        var bomOfferList = from bomOffer in entity.publicbomoffer
                                           join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                           join a in entity.account on bomOffer.userID equals a.id
                                           where custVen.custVendorType == (int)this.bomOfferType && (custVen.custVenName.Contains(tstbFilterString.Text.Trim()))
                                           orderby bomOffer.bomOfferId descending
                                           select new
                                           {
                                               Id = bomOffer.bomOfferId,
                                               Company = "OEM",
                                               MFG = bomOffer.mfg,
                                               MPN = bomOffer.mpn,
                                               Qty = bomOffer.qty,
                                               Price = bomOffer.price,
                                               CPN = "OEM",
                                               Owner = a.accountName,
                                               Enterday = bomOffer.enerDay
                                           };
                        this.dataGridView1.DataSource = bomOfferList;
                        this.dataGridView1.Columns[0].Visible = false;

                    }
                }

            }
            else if ((tscbFilterBy.Text.Trim() == "MPN") && (tstbFilterString.Text.Trim().Length != 0))
            {
                using (BomOfferEntities entity = new BomOfferEntities())
                {
                    if (listbyCustVen)
                    {

                        this.dataGridView1.DataSource = null;
                        if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && (bomOffer.mpn.Contains(tstbFilterString.Text.Trim())
                                               && (custVen.custVenId == this.custVenId))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                                               {
                                                   Id = bomOffer.bomOfferId,
                                                   Company = custVen.custVenName,
                                                   MFG = bomOffer.mfg,
                                                   MPN = bomOffer.mpn,
                                                   Qty = bomOffer.qty,
                                                   Price = bomOffer.price,
                                                   CPN = bomOffer.cpn,
                                                   Owner = a.accountName,
                                                   Enterday = bomOffer.enerDay
                                               };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                        else
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && (bomOffer.mpn.Contains(tstbFilterString.Text.Trim())
                                               && (custVen.custVenId == this.custVenId))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                                               {
                                                   Id = bomOffer.bomOfferId,
                                                   Company = "OEM",
                                                   MFG = bomOffer.mfg,
                                                   MPN = bomOffer.mpn,
                                                   Qty = bomOffer.qty,
                                                   Price = bomOffer.price,
                                                   CPN = "OEM",
                                                   Owner = a.accountName,
                                                   Enterday = bomOffer.enerDay
                                               };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;

                        }

                    }
                    else
                    {

                        this.dataGridView1.DataSource = null;
                        if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && (bomOffer.mpn.Contains(tstbFilterString.Text.Trim()))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                                               {
                                                   Id = bomOffer.bomOfferId,
                                                   Company = custVen.custVenName,
                                                   MFG = bomOffer.mfg,
                                                   MPN = bomOffer.mpn,
                                                   Qty = bomOffer.qty,
                                                   Price = bomOffer.price,
                                                   CPN = bomOffer.cpn,
                                                   Owner = a.accountName,
                                                   Enterday = bomOffer.enerDay
                                               };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                        else
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && (bomOffer.mpn.Contains(tstbFilterString.Text.Trim()))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                                               {
                                                   Id = bomOffer.bomOfferId,
                                                   Company = "OEM",
                                                   MFG = bomOffer.mfg,
                                                   MPN = bomOffer.mpn,
                                                   Qty = bomOffer.qty,
                                                   Price = bomOffer.price,
                                                   CPN = "OEM",
                                                   Owner = a.accountName,
                                                   Enterday = bomOffer.enerDay
                                               };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                    }
                }

            }

            else if ((tscbFilterBy.Text.Trim() == "Date") && (tstbFilterString.Text.Trim().Length != 0))
            {
                string[] date = AmbleClient.RfqGui.RfqManager.RfqMgr.GetStartDateAndEndDate(tstbFilterString.Text.Trim());
                if (string.IsNullOrWhiteSpace(date[0]) || string.IsNullOrWhiteSpace(date[1]))
                {
                    MessageBox.Show("Format error in the Filter String");
                    return;
                }
                DateTime startDate,endDate;

                try{
                   startDate=DateTime.Parse(date[0]);
                   endDate=DateTime.Parse(date[1]);
                }
                catch
                {
                    MessageBox.Show("Format error in the Filter String");
                    return;
                }

                using (BomOfferEntities entity = new BomOfferEntities())
                {
                    if (listbyCustVen)
                    {
                        this.dataGridView1.DataSource = null;
                        if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where (custVen.custVendorType == (int)this.bomOfferType && ((bomOffer.enerDay.HasValue) && (bomOffer.enerDay.Value > startDate) && (bomOffer.enerDay.Value < endDate))
                                               && (custVen.custVenId == this.custVenId))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                                               {
                                                   Id = bomOffer.bomOfferId,
                                                   Company = custVen.custVenName,
                                                   MFG = bomOffer.mfg,
                                                   MPN = bomOffer.mpn,
                                                   Qty = bomOffer.qty,
                                                   Price = bomOffer.price,
                                                   CPN = bomOffer.cpn,
                                                   Owner = a.accountName,
                                                   Enterday = bomOffer.enerDay
                                               };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                        else
                        {
                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where (custVen.custVendorType == (int)this.bomOfferType && ((bomOffer.enerDay.HasValue) && (bomOffer.enerDay.Value > startDate) && (bomOffer.enerDay.Value < endDate))
                                               && (custVen.custVenId == this.custVenId))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                                               {
                                                   Id = bomOffer.bomOfferId,
                                                   Company = "OEM",
                                                   MFG = bomOffer.mfg,
                                                   MPN = bomOffer.mpn,
                                                   Qty = bomOffer.qty,
                                                   Price = bomOffer.price,
                                                   CPN = "OEM",
                                                   Owner = a.accountName,
                                                   Enterday = bomOffer.enerDay
                                               };
                            dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }

                    }
                    else
                    {

                        this.dataGridView1.DataSource = null;
                        if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                        {

                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && ((bomOffer.enerDay.HasValue) && (bomOffer.enerDay.Value > startDate) && (bomOffer.enerDay.Value < endDate))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                                               {
                                                   Id = bomOffer.bomOfferId,
                                                   Company = custVen.custVenName,
                                                   MFG = bomOffer.mfg,
                                                   MPN = bomOffer.mpn,
                                                   Qty = bomOffer.qty,
                                                   Price = bomOffer.price,
                                                   CPN = bomOffer.cpn,
                                                   Owner = a.accountName,
                                                   Enterday = bomOffer.enerDay
                                               };
                            this.dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;
                        }
                        else
                        {

                            var bomOfferList = from bomOffer in entity.publicbomoffer
                                               join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                               join a in entity.account on bomOffer.userID equals a.id
                                               where custVen.custVendorType == (int)this.bomOfferType && ((bomOffer.enerDay.HasValue) && (bomOffer.enerDay.Value > startDate) && (bomOffer.enerDay.Value < endDate))
                                               orderby bomOffer.bomOfferId descending
                                               select new
                                               {
                                                   Id = bomOffer.bomOfferId,
                                                   Company = "OEM",
                                                   MFG = bomOffer.mfg,
                                                   MPN = bomOffer.mpn,
                                                   Qty = bomOffer.qty,
                                                   Price = bomOffer.price,
                                                   CPN = "OEM",
                                                   Owner =a.accountName,
                                                   Enterday = bomOffer.enerDay
                                               };
                            this.dataGridView1.DataSource = bomOfferList;
                            this.dataGridView1.Columns[0].Visible = false;

                        }
                    }
                }

            }

            else
            { }
        }
Exemplo n.º 18
0
        private void tsbListAll_Click(object sender, EventArgs e)
        {
            listAll = true;
             dataGridView1.DataSource = null;
             using (BomOfferEntities entity = new BomOfferEntities())
             {
                 if (listbyCustVen)
                 {

                     if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                     {
                         var bomOfferList = from bomOffer in entity.publicbomoffer
                                            join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                            join a in entity.account on bomOffer.userID equals a.id
                                            where custVen.custVendorType == (int)this.bomOfferType && custVen.custVenId == this.custVenId
                                            orderby bomOffer.bomOfferId descending
                                            select new
                                            {
                                                Id = bomOffer.bomOfferId,
                                                Company = custVen.custVenName,
                                                MFG = bomOffer.mfg,
                                                MPN = bomOffer.mpn,
                                                Qty = bomOffer.qty,
                                                Price = bomOffer.price,
                                                Owner = a.accountName,
                                                CPN = bomOffer.cpn,
                                                Enterday = bomOffer.enerDay
                                            };
                         dataGridView1.DataSource = bomOfferList;
                         this.dataGridView1.Columns[0].Visible = false;

                     }
                     else
                     {
                         var bomOfferList = from bomOffer in entity.publicbomoffer
                                            join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                            join a in entity.account on bomOffer.userID equals a.id
                                            where custVen.custVendorType == (int)this.bomOfferType && custVen.custVenId == this.custVenId
                                            orderby bomOffer.bomOfferId descending
                                            select new
                                            {
                                                Id = bomOffer.bomOfferId,
                                                Company = "OEM",
                                                MFG = bomOffer.mfg,
                                                MPN = bomOffer.mpn,
                                                Qty = bomOffer.qty,
                                                Price = bomOffer.price,
                                                Owner = a.accountName,
                                                CPN = "OEM",
                                                Enterday = bomOffer.enerDay
                                            };
                         dataGridView1.DataSource = bomOfferList;
                         this.dataGridView1.Columns[0].Visible = false;
                     }

                 }

                 else
                 {
                    if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
                     {

                         var bomOfferList = from bomOffer in entity.publicbomoffer
                                            join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                            join a in entity.account on bomOffer.userID equals a.id
                                            where custVen.custVendorType == (int)this.bomOfferType
                                            orderby bomOffer.bomOfferId descending
                                            select new
                                            {
                                                Id = bomOffer.bomOfferId,
                                                Company = custVen.custVenName,
                                                MFG = bomOffer.mfg,
                                                MPN = bomOffer.mpn,
                                                Qty = bomOffer.qty,
                                                Price = bomOffer.price,
                                                CPN = bomOffer.cpn,
                                                Ower=a.accountName,
                                                Enterday = bomOffer.enerDay
                                            };

                         dataGridView1.DataSource = bomOfferList;
                         this.dataGridView1.Columns[0].Visible = false;

                     }
                     else
                     {
                         var bomOfferList = from bomOffer in entity.publicbomoffer
                                            join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                            join a in entity.account on bomOffer.userID equals a.id
                                            where custVen.custVendorType == (int)this.bomOfferType
                                            orderby bomOffer.bomOfferId descending
                                            select new
                                            {
                                                Id = bomOffer.bomOfferId,
                                                Company = "OEM",
                                                MFG = bomOffer.mfg,
                                                MPN = bomOffer.mpn,
                                                Qty = bomOffer.qty,
                                                Price = bomOffer.price,
                                                CPN = "OEM",
                                                Owner = a.accountName,
                                                Enterday = bomOffer.enerDay
                                            };

                         //AllAccountInfo.GetNameAccordingToId
                         dataGridView1.DataSource = bomOfferList;
                         this.dataGridView1.Columns[0].Visible = false;
                     }

                 }

             }
        }
Exemplo n.º 19
0
        private void tsbExportFromExcel_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

            DataGridViewRow dgvr      = dataGridView1.SelectedRows[0];
            int             custVenId = Convert.ToInt32(dgvr.Cells["Id"].Value);


            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "Excel文件(*.xls)|*.xls";
            ofd.RestoreDirectory = true;
            ofd.Multiselect      = false;

            if (DialogResult.OK == ofd.ShowDialog())
            {
                DataTable dt = ExcelHelper.ExcelHelper.Import(ofd.FileName);
                if (dt.Rows.Count == 0)
                {
                    return;
                }

                bool hasCpn = false, hasMpn = false, hasMfg = false, hasQty = false, hasPrice = false;
                int  cpnColumn = -1, mpnColumn = -1, mfgColumn = -1, qtyColumn = -1, priceColumn = -1;
                foreach (DataColumn dc in dt.Columns)
                {
                    if (dc.ColumnName.Trim().ToUpper() == "MPN")
                    {
                        hasMpn    = true;
                        mpnColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "CPN")
                    {
                        hasCpn    = true;
                        cpnColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "MFG")
                    {
                        hasMfg    = true;
                        mfgColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "QTY")
                    {
                        hasQty    = true;
                        qtyColumn = dt.Columns.IndexOf(dc);
                    }
                    if (dc.ColumnName.Trim().ToUpper() == "PRICE")
                    {
                        hasPrice    = true;
                        priceColumn = dt.Columns.IndexOf(dc);
                    }
                }
                if (false == (hasPrice && hasMpn && hasCpn && hasMfg && hasQty))
                {
                    MessageBox.Show("Please check the xls File Column.(CPN,MPN,MFG,QTY,PRICE)");
                    return;
                }

                //  List<publicbomoffer> publicbomOfferList = new List<publicbomoffer>();
                using (BomOfferEntities entity = new BomOfferEntities())
                { int i = 1;
                  foreach (DataRow dr in dt.Rows)
                  {
                      //Qty omit the ","

                      string qtyString = dr[qtyColumn].ToString();
                      qtyString = qtyString.Replace(",", string.Empty);

                      if (!string.IsNullOrWhiteSpace(qtyString) && (!ItemsCheck.CheckIntNumber(qtyString)))
                      {
                          MessageBox.Show("The Qty value is not correct in row " + i.ToString());
                          return;
                      }
                      if (!string.IsNullOrWhiteSpace(dr[priceColumn].ToString()) && (!ItemsCheck.CheckFloatNumber(dr[priceColumn])))
                      {
                          MessageBox.Show("The Price value is not correct in row " + i.ToString());
                          return;
                      }

                      int?  qtyLocal;
                      float?priceLocal;

                      if (string.IsNullOrWhiteSpace(qtyString))
                      {
                          qtyLocal = null;
                      }
                      else
                      {
                          qtyLocal = Convert.ToInt32(qtyString);
                      }

                      if (string.IsNullOrWhiteSpace(dr[priceColumn].ToString()))
                      {
                          priceLocal = null;
                      }
                      else
                      {
                          priceLocal = Convert.ToSingle(dr[priceColumn]);
                      }


                      entity.publicbomoffer.AddObject(
                          new publicbomoffer
                        {
                            mfg           = dr[mfgColumn].ToString(),
                            mpn           = dr[mpnColumn].ToString(),
                            qty           = qtyLocal,
                            price         = priceLocal,
                            cpn           = dr[cpnColumn].ToString(),
                            userID        = (short)UserInfo.UserId,
                            BomCustVendId = custVenId,
                            enerDay       = DateTime.Now
                        }

                          );
                      i++;
                  }
                  entity.SaveChanges(); }

                MessageBox.Show("Import file " + ofd.FileName + " successfully.");
            }
        }
Exemplo n.º 20
0
        private void FillTheDataGrid()
        {
            this.dataGridView1.Rows.Clear();
            using (BomOfferEntities entity = new BomOfferEntities())
            {
                if (tscbSearchBy.SelectedIndex < 0 || tstbFilterString.Text.Trim().Length == 0)
                {

                    var bomOfferList = from bomOffer in entity.publiccustven
                                       join myaccount in entity.account on bomOffer.userID equals myaccount.id
                                       where bomOffer.custVendorType == (int)bomOfferType
                                       orderby bomOffer.enterDay descending
                                       select new
                                       {
                                           Id = bomOffer.custVenId,
                                           Name = bomOffer.custVenName,
                                           Contact = bomOffer.contact,
                                           Tel = bomOffer.tel,
                                           Email = bomOffer.email,
                                           User = myaccount.accountName,
                                           EnterDay = bomOffer.enterDay
                                       };
                    foreach (var bomOffer in bomOfferList)
                    {
                        dataGridView1.Rows.Add(bomOffer.Id, bomOffer.Name, bomOffer.Contact, bomOffer.Tel, bomOffer.Email, bomOffer.User, bomOffer.EnterDay);

                    }
                }
                else
                {

                    var bomOfferList = from bomOffer in entity.publiccustven
                                       join myaccount in entity.account on bomOffer.userID equals myaccount.id
                                       where bomOffer.custVendorType == ((int)bomOfferType) &&bomOffer.custVenName.Contains(tstbFilterString.Text.Trim())
                                       orderby bomOffer.enterDay descending
                                       select new
                                       {
                                           Id = bomOffer.custVenId,
                                           Name = bomOffer.custVenName,
                                           Contact = bomOffer.contact,
                                           Tel = bomOffer.tel,
                                           Email = bomOffer.email,
                                           User = myaccount.accountName,
                                           EnterDay = bomOffer.enterDay
                                       };
                    foreach (var bomOffer in bomOfferList)
                    {
                        dataGridView1.Rows.Add(bomOffer.Id, bomOffer.Name, bomOffer.Contact, bomOffer.Tel, bomOffer.Email, bomOffer.User, bomOffer.EnterDay);

                    }

                }

            }
        }
Exemplo n.º 21
0
        private void tsbDelete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0) return;

            if (MessageBox.Show("Delete the selected customer/vendor will also delete its related BOM/Offer", "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                return;

            DataGridViewRow dgvr = dataGridView1.SelectedRows[0];
            int custVenIdSelected = Convert.ToInt32(dgvr.Cells["Id"].Value);

            using (BomOfferEntities entity = new BomOfferEntities())
            {
                var bomOfferList = entity.publicbomoffer.Where(bomOffer => bomOffer.BomCustVendId == custVenIdSelected);
                foreach (var bomOffer in bomOfferList)
                {
                    entity.DeleteObject(bomOffer);
                }

                entity.DeleteObject(entity.publiccustven.Where(cv => cv.custVenId == custVenIdSelected).First());

                entity.SaveChanges();

            }

            BomOfferCustVendor_Load(this, null);
        }
Exemplo n.º 22
0
        private void BomOfferList_Load(object sender, EventArgs e)
        {
            if (isOffer)
            {
                this.Text = "Offers List";
            }
            else
            {
                this.Text = "BOMs List";
            }

            if (listbyCustVen)
            {
                tscbFilterBy.Enabled     = false;
                tstbFilterString.Enabled = false;
                tsbSearch.Enabled        = false;
                tsbCancel.Enabled        = false;
            }


            using (BomOfferEntities entity = new BomOfferEntities())
            {
                if (listbyCustVen)
                {
                    var bomOfferList = from bomOffer in entity.publicbomoffer
                                       join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                       where custVen.custVendorType == (isOffer ? 1 : 0) && custVen.custVenId == this.custVenId

                                       select new
                    {
                        Id    = bomOffer.BomCustVendId,
                        MFG   = bomOffer.mfg,
                        MPN   = bomOffer.mpn,
                        Qty   = bomOffer.qty,
                        Price = bomOffer.price,
                        Cpn   = bomOffer.cpn
                    };

                    this.dataGridView1.DataSource = bomOfferList;
                }

                else
                {
                    var bomOfferList = from bomOffer in entity.publicbomoffer
                                       join custVen in entity.publiccustven on bomOffer.BomCustVendId equals custVen.custVenId
                                       where custVen.custVendorType == (isOffer ? 1 : 0)
                                       select new
                    {
                        Id      = bomOffer.BomCustVendId,
                        Company = custVen.custVenName,
                        MFG     = bomOffer.mfg,
                        MPN     = bomOffer.mpn,
                        Qty     = bomOffer.qty,
                        Price   = bomOffer.price,
                        Cpn     = bomOffer.cpn
                    };

                    this.dataGridView1.DataSource = bomOfferList;
                }
            }
        }
Exemplo n.º 23
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!ItemsCheck.CheckTextBoxEmpty(tbMfg))
            {
                MessageBox.Show("Please input the MFG");
                return;

            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbMpn))
            {
                MessageBox.Show("Please input the MPN");
                return;
            }

            if (!ItemsCheck.CheckIntNumber(tbQty))
            {
                MessageBox.Show("The QTY should be an integer value");
                tbQty.Focus();
                return;
            }

            if (!ItemsCheck.CheckTextBoxEmpty(tbPrice))
            {
                MessageBox.Show("Please input the Price");
                return;

            }
            else
            {
                if (!ItemsCheck.CheckFloatNumber(tbPrice))
                {
                    MessageBox.Show("The Price should be a float number");
                    tbPrice.Focus();
                    return;

                }
            }

            var publicBomOff = new publicbomoffer
            {
                mfg = tbMfg.Text.Trim().ToUpper(),
                mpn = tbMpn.Text.Trim().ToUpper(), //upper
                qty = int.Parse(tbQty.Text.Trim()),
                price = float.Parse(tbPrice.Text.Trim()),
                cpn = tbCpn.Text.Trim().ToUpper(),
                userID = (short)UserInfo.UserId,
                BomCustVendId=this.custVenId,
                enerDay = DateTime.Now
            };
            using (BomOfferEntities entity = new BomOfferEntities())
            {
                entity.publicbomoffer.AddObject(publicBomOff);
                entity.SaveChanges();
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 24
0
        private void tsbDeleteItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0) return;
            if (MessageBox.Show("Delete the selected item?", "Delete", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            DataGridViewSelectedRowCollection dgvrrc = dataGridView1.SelectedRows;
            int bomOfferId;

            using (BomOfferEntities entity = new BomOfferEntities())
            {
                foreach (DataGridViewRow dgvr in dgvrrc)
                {
                    bomOfferId = Convert.ToInt32(dgvr.Cells["Id"].Value);
                    var bomOfferItem = entity.publicbomoffer.First(item => item.bomOfferId == bomOfferId);
                    entity.publicbomoffer.DeleteObject(bomOfferItem);
                }
                entity.SaveChanges();
            }
            if (listAll)
            {
                tsbListAll_Click(this, null);
            }
            else
            {
                tsbSearch_Click(this, null);
            }
        }