Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string pwd = textBox2.Text.Trim().ToString();

            if (textBox2.Text.Trim().Length == 0 || textBox3.Text.Trim() != textBox2.Text.Trim())
            {
                MessageBox.Show("Failed, password and confirm password are not equal or empty!", "System", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    using (var ctx = new ItemContext())
                    {
                        User user = new User()
                        {
                            UserName = uname, UserPwd = textBox2.Text.Trim().ToString()
                        };
                        ctx.Users.Attach(user);
                        ctx.Entry(user).State = System.Data.Entity.EntityState.Modified;
                        ctx.Entry(user).Property(x => x.UserType).IsModified = false;
                        ctx.SaveChanges();
                        MessageBox.Show("Password Successfully Changed!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in dataGridView1.Rows)
     {
         if (row.Selected)
         {
             try
             {
                 using (var ctx = new ItemContext())
                 {
                     ItemInbound it = new ItemInbound();
                     it.ItemInboundId = Convert.ToInt32(row.Cells[0].Value.ToString());
                     it.isDelete      = false;
                     ctx.ItemInbounds.Attach(it);
                     ctx.Entry(it).State = System.Data.Entity.EntityState.Unchanged;
                     ctx.Entry(it).Property(p => p.isDelete).IsModified = true;
                     ctx.SaveChanges();
                     MessageBox.Show("Restore successfully.");
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
     fillBy1ToolStripButton_Click(this, e);
 }
Пример #3
0
        private void ReadyToOut_Click(object sender, EventArgs e)
        {
            int    position   = dataGridView1.Rows.GetFirstRow(DataGridViewElementStates.Selected);
            string currentRow = dataGridView1.Rows[position].Cells["SN"].Value.ToString();

            try
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (Convert.ToBoolean(row.Cells["Selected"].Value))
                    {
                        using (var ctx = new ItemContext())
                        {
                            string rdy       = row.Cells["SN"].Value.ToString();
                            var    pending   = ctx.Items.Where(sn => sn.SN == rdy).Select(x => x.Pending).First();
                            var    condition = ctx.Items.Where(sn => sn.SN == rdy).Select(x => x.Condition).First();
                            if (pending == null)
                            {
                                pending = false;
                            }
                            if (condition == null)
                            {
                                MessageBox.Show("The item without condition cannot set to rdy.");
                                return;
                            }
                            if (condition.Contains("unchecked") || condition.Contains("Unchecked") || condition.Contains("Defective"))
                            {
                                MessageBox.Show(condition.ToString() + " Item Cannot set to rdy to out");
                                return;
                            }
                            Item ite = new Item()
                            {
                                SN = row.Cells["SN"].Value.ToString(), Pending = !Convert.ToBoolean(pending.Value)
                            };
                            ctx.Entry <Item>(ite).State = EntityState.Unchanged;
                            ctx.Entry <Item>(ite).Property(p => p.Pending).IsModified = true;
                            ctx.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (ItemTitle.Text.Length != 0 || OrderId.Text.Length != 0 || UPC.Text.Length != 0 ||
                    SN.Text.Length != 0 || RcvTime.Checked || Condition.Text.Length != 0 || pendingBox.Checked ||
                    location.Text.Trim().Length != 0 || LPN.Text.Trim().Length != 0 || TrackingNum.Text.Trim().Length != 0)
                {
                    Search_Click(this, e);
                }
                else
                {
                    ReLoadData();
                }
                st.returnCurrentRow(currentRow, dataGridView1);
            }
        }
Пример #4
0
 private void Modify_Click(object sender, EventArgs e)
 {
     if (userName.Text.Trim().Length != 0)
     {
         try
         {
             using (var ctx = new ItemContext())
             {
                 User u = new User()
                 {
                     UserName = userName.Text.Trim(), UserPwd = pwd.Text.Trim(), UserType = userType.Text
                 };
                 ctx.Users.Attach(u);
                 ctx.Entry(u).State = System.Data.Entity.EntityState.Modified;
                 ctx.SaveChanges();
                 MessageBox.Show("Successfully Updated!");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             Clear_Click(this, e);
         }
     }
     else
     {
         MessageBox.Show("Please select one user!");
     }
 }
Пример #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (itemTitile.Text.Length != 0 && UPC.Text.Length != 0 && date.Text.Length != 0 && TrackingNumLabel.Text.Length != 0)
     {
         try
         {
             using (var ctx = new ItemContext())
             {
                 ItemInbound itemInbound = ctx.ItemInbounds.Where(u => u.ItemInboundId == itemInboundId).FirstOrDefault();
                 itemInbound.ItemTitle        = itemTitile.Text;
                 itemInbound.Date             = Convert.ToDateTime(date.Text);
                 itemInbound.Qty              = Convert.ToInt32(Qty.Text);
                 itemInbound.UPC              = UPC.Text;
                 itemInbound.TrackingNum      = TrackingNum.Text;
                 itemInbound.ShipperId        = tbShipperID.Text;
                 ctx.Entry(itemInbound).State = System.Data.Entity.EntityState.Modified;
                 ctx.SaveChanges();
                 MessageBox.Show("Successfully updated!");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Пример #6
0
        private void SaveAll_Click(object sender, EventArgs e)
        {
            if (itemTitile.Text.Trim().Length > 0 || location.Text.Trim().Length > 0 ||
                listed.Text.Trim().Length > 0 || condition.Text.Trim().Length > 0 ||
                note.Text.Trim().Length > 0 || upc.Text.Trim().Length > 0)
            {
                foreach (string sn in SN)
                {
                    try
                    {
                        using (ItemContext ctx = new ItemContext())
                        {
                            Item it = ctx.Items.Find(sn);
                            it.ServiceMan = uname;
                            foreach (Control ctr in this.Controls)
                            {
                                if (ctr.Text.Trim().Length != 0)
                                {
                                    switch (ctr.Name)
                                    {
                                    case "itemTitile":
                                        it.ItemTitle = ctr.Text.Trim();
                                        break;

                                    case "location":
                                        it.Location = ctr.Text.Trim();
                                        break;

                                    case "listed":
                                        it.Listed = ctr.Text.Trim();
                                        break;

                                    case "condition":
                                        it.Condition = ctr.Text.Trim();
                                        break;

                                    case "upc":
                                        it.UPC = ctr.Text.Trim();
                                        break;

                                    case "note":
                                        it.Note = ctr.Text.Trim();
                                        break;
                                    }
                                }
                            }
                            ctx.Items.Attach(it);
                            ctx.Entry(it).State = System.Data.Entity.EntityState.Modified;
                            ctx.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                        return;
                    }
                }
                MessageBox.Show("Successfull updated multiple items!");
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Nothing can be updated!");
            }
        }
Пример #7
0
        private void Delete_Click(object sender, EventArgs e)
        {
            bool del         = false;
            bool select      = false;
            int  indexDelete = 0;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (Convert.ToBoolean(row.Cells["Selected"].Value))
                {
                    select = true;
                }
            }
            if (select)
            {
                if (MessageBox.Show("This record will be deleted!", "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells["Selected"].Value))
                        {
                            int idDelete = Convert.ToInt32(row.Cells["ItemOutboundId"].Value.ToString());
                            indexDelete = indexDelete == 0 ? row.Index - 1 : indexDelete;
                            //string trackingDelete = row.Cells["TrackingNum"].Value.ToString();
                            try
                            {
                                using (var ctx = new ItemContext())
                                {
                                    ItemOutbound itemOutboundDel = new ItemOutbound();
                                    itemOutboundDel.ItemOutboundId = idDelete;
                                    itemOutboundDel.isDelete       = true;
                                    ctx.ItemOutbounds.Attach(itemOutboundDel);
                                    ctx.Entry(itemOutboundDel).Property(x => x.isDelete).IsModified = true;
                                    ctx.SaveChanges();
                                    del = true;
                                }
                            }
                            catch (Exception ex)
                            {
                                del = false;
                                MessageBox.Show(ex.Message);
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("No item selected!");
            }
            if (del) // deleted
            {
                del = false;
                if (ItemTitle.Text.Length != 0 || SN.Text.Length != 0 ||
                    OutBoundDate.Checked || Manipulator.Text.Length != 0 ||
                    TrackingNum.Text.Trim().Length != 0)
                {
                    Search_Click(this, e);
                }
                else
                {
                    ReLoadData();
                }
                st.returnCurrentRow(indexDelete, dataGridView1);
            }
        }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (itemTitile.Text.Length != 0 && orderId.Text.Length != 0 && SN.Text.Length != 0 && condition.Text.Length != 0)
            {
                try
                {
                    //determine editors
                    editor = editorMaker(editor);
                    if (SN.ReadOnly)
                    {
                        using (var ctx = new ItemContext())
                        {
                            Item ite;
                            if (utype == "serviceMan")
                            {
                                //Item it = ctx.Items.SingleOrDefault(a => a.SN == snCode);
                                //it.ItemTitle = itemTitile.Text.Trim();
                                //it.DateOfRcv = Convert.ToDateTime(dateOfRcv.Text);
                                //it.OrderId = orderId.Text.Trim();
                                //it.UPC = UPC.Text.Trim();
                                //it.SN = SN.Text.Trim();
                                //it.ReturnCode = returnCode.Text.Trim();
                                //it.Location = location.Text.Trim();
                                //it.Listed = listed.Text;
                                //it.ServiceMan = uname;
                                //it.Condition = condition.Text;
                                //it.OriginalTrackingNum = originalTrackingNum.Text.Trim();
                                //it.Note = Note.Text.Trim();

                                //ctx.Items.Attach(it);
                                //ctx.Entry(it).State = System.Data.Entity.EntityState.Modified;

                                ite = new Item()
                                {
                                    ItemTitle           = itemTitile.Text.Trim(),
                                    DateOfRcv           = Convert.ToDateTime(dateOfRcv.Text),
                                    OrderId             = orderId.Text.Trim(),
                                    UPC                 = UPC.Text.Trim(),
                                    SN                  = SN.Text.Trim(),
                                    OriginalTrackingNum = originalTrackingNum.Text.Trim(),
                                    ReturnCode          = returnCode.Text.Trim(),
                                    Location            = location.Text.Trim(),
                                    Listed              = listed.Text,
                                    ServiceMan          = editor,
                                    Condition           = condition.Text,
                                    Note                = Note.Text.Trim()
                                };
                                ctx.Items.Attach(ite);
                                ctx.Entry(ite).State = System.Data.Entity.EntityState.Modified;
                                ctx.Entry(ite).Property(x => x.ItemInOperator).IsModified = false;
                                ctx.Entry(ite).Property(y => y.Pending).IsModified        = false;
                            }
                            else
                            {
                                ite = new Item()
                                {
                                    ItemTitle           = itemTitile.Text.Trim(),
                                    DateOfRcv           = Convert.ToDateTime(dateOfRcv.Text),
                                    OrderId             = orderId.Text.Trim(),
                                    UPC                 = UPC.Text.Trim(),
                                    SN                  = SN.Text.Trim(),
                                    OriginalTrackingNum = originalTrackingNum.Text.Trim(),
                                    ReturnCode          = returnCode.Text.Trim(),
                                    Location            = location.Text.Trim(),
                                    Listed              = listed.Text,
                                    Condition           = condition.Text,
                                    Note                = Note.Text.Trim()
                                };
                                ctx.Items.Attach(ite);
                                ctx.Entry(ite).State = System.Data.Entity.EntityState.Modified;
                                ctx.Entry(ite).Property(x => x.ItemInOperator).IsModified = false;
                                ctx.Entry(ite).Property(x => x.ServiceMan).IsModified     = false;
                                ctx.Entry(ite).Property(y => y.Pending).IsModified        = false;
                            }
                            ctx.SaveChanges();
                            MessageBox.Show("Successfully updated!");
                            this.Dispose(true);
                        }
                    }
                    else
                    {
                        try
                        {
                            using (ItemContext ctx = new ItemContext())
                            {
                                Item it    = ctx.Items.SingleOrDefault(a => a.SN == snCode);
                                Item itNew = new Item()
                                {
                                    ItemTitle           = itemTitile.Text.Trim(),
                                    OrderId             = orderId.Text.Trim(),
                                    UPC                 = UPC.Text.Trim(),
                                    SN                  = SN.Text.Trim(),
                                    OriginalTrackingNum = originalTrackingNum.Text.Trim(),
                                    ReturnCode          = returnCode.Text.Trim(),
                                    Location            = location.Text.Trim(),
                                    DateOfRcv           = Convert.ToDateTime(dateOfRcv.Text.ToString()),
                                    Listed              = listed.Text,
                                    ItemInOperator      = it.ItemInOperator,
                                    Condition           = condition.Text,
                                    Note                = Note.Text.Trim(),
                                    Pending             = it.Pending,
                                    ServiceMan          = editorMaker(editor)
                                };
                                ctx.Items.Remove(it);
                                ctx.Items.Add(itNew);
                                ctx.SaveChanges();
                                MessageBox.Show("Successfully updated!");
                                snCode = SN.Text;
                                this.Dispose(true);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                }
            }
            else
            {
                MessageBox.Show("Item title, order ID, and Condition are required. ");
            }
        }