コード例 #1
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            FmSale fmSale = new FmSale();

            fmSale.Show();
            this.Close();
        }
コード例 #2
0
        private async void btnDelete_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show(DefineMessage.CONFIRM_DELETE_RECORD, CommonDefines.MESSAGEBOX_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                ORDER order = db.ORDERS.Where(o => o.ID == Oid).FirstOrDefault();

                db.ORDERS.Remove(order);
                await db.SaveChangesAsync();

                MessageBox.Show(DefineMessage.DELETE_RECORD_SUCCESSFUL, CommonDefines.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                FmSale fmSale = new FmSale();
                fmSale.Show();
                this.Close();
            }
        }
コード例 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ORDER   od   = db.ORDERS.Where(p => p.ID == this.order.ID).FirstOrDefault();
            PRODUCT prod = db.PRODUCTs.Where(p => p.ID.Equals(order.PRODUCT)).FirstOrDefault();
            int     totalNumberProduct = (int)order.PRODUCTNUMBER + (int)prod.NUMBER;
            int     initNumber         = (int)order.PRODUCTNUMBER;

            od.BUYER            = tbName.Text;
            od.BUYERPHONENUMBER = tbPhoneNum.Text;
            od.PRODUCT          = getSelectedProduct();
            od.PRODUCTNUMBER    = int.Parse(tbNumber.Text);
            od.MONEYRECEIVED    = int.Parse(tbreceive.Text);
            od.EXCESSCASH       = int.Parse(tbBackMoney.Text);

            db.Entry(od).State = System.Data.Entity.EntityState.Modified;



            if (totalNumberProduct < od.PRODUCTNUMBER)
            {
                MessageBox.Show(DefineMessage.NOT_ENOUGH_PRODUCT, CommonDefines.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                if (od.PRODUCTNUMBER > initNumber)
                {
                    prod.NUMBER = prod.NUMBER - (od.PRODUCTNUMBER - initNumber);
                }
                else
                {
                    prod.NUMBER = prod.NUMBER + (initNumber - od.PRODUCTNUMBER);
                }
            }

            db.Entry(prod).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            MessageBox.Show(DefineMessage.MODIFY_SUCCESSFUL, CommonDefines.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
            FmSale fmSale = new FmSale();

            fmSale.Show();
        }
コード例 #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ORDER order = new ORDER();

            order.SELLER           = CommonDefines.currentUser;
            order.BUYER            = tbName.Text;
            order.BUYERPHONENUMBER = tbPhoneNum.Text;
            order.PRODUCT          = getSelectedProduct();
            order.PRODUCTNUMBER    = int.Parse(tbNumber.Text);
            order.MONEYRECEIVED    = int.Parse(tbreceive.Text);
            order.EXCESSCASH       = int.Parse(tbBackMoney.Text);
            order.DATECREATE       = DateTime.Now;
            order.STATUSS          = 1;

            db.ORDERS.Add(order);

            PRODUCT prod = db.PRODUCTs.Where(p => p.ID.Equals(order.PRODUCT)).FirstOrDefault();

            if (prod.NUMBER >= order.PRODUCTNUMBER)
            {
                prod.NUMBER = prod.NUMBER - order.PRODUCTNUMBER;
            }
            else
            {
                MessageBox.Show(DefineMessage.NOT_ENOUGH_PRODUCT, CommonDefines.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            db.Entry(prod).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            MessageBox.Show(DefineMessage.ADD_RECORD_SUCCESSFUL, CommonDefines.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
            FmSale fmSale = new FmSale();

            fmSale.Show();
        }