コード例 #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            VoucherForm form = VoucherForm.Instance;

            form.TopLevel = false;
            this.contentPanel.Controls.Clear();
            this.contentPanel.Controls.Add(form);
            form.Dock = DockStyle.Fill;
            form.Show();
        }
コード例 #2
0
        public JsonResult addVoucher(VoucherForm voucherForm)
        {
            System.Diagnostics.Debug.WriteLine("name " + voucherForm.Name);
            System.Diagnostics.Debug.WriteLine("product id " + voucherForm.ProductId);
            System.Diagnostics.Debug.WriteLine("voucher id " + voucherForm.VoucherId);
            System.Diagnostics.Debug.WriteLine("price " + voucherForm.Price);
            System.Diagnostics.Debug.WriteLine("start " + voucherForm.StartDate);
            System.Diagnostics.Debug.WriteLine("end " + voucherForm.EndDate);
            string message = "";


            //update
            if (voucherForm.VoucherId != 0)
            {
                voucher  v         = db.vouchers.Find(voucherForm.VoucherId);
                DateTime startDate = DateTime.Parse(voucherForm.StartDate);

                DateTime endDate = DateTime.Parse(voucherForm.EndDate);
                v.startDate = startDate;
                v.endDate   = endDate;
                v.name      = voucherForm.Name;
                v.product   = db.products.Find(voucherForm.ProductId);
                v.price     = voucherForm.Price;

                db.Entry(v).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                voucher v = new voucher();
                v.name    = voucherForm.Name;
                v.price   = voucherForm.Price;
                v.product = db.products.Find(voucherForm.ProductId);
                DateTime startDate = DateTime.Parse(voucherForm.StartDate);

                DateTime endDate = DateTime.Parse(voucherForm.EndDate);
                v.startDate  = startDate;
                v.endDate    = endDate;
                v.createDate = DateTime.Now;
                v.updateDate = DateTime.Now;
                v.activeFlag = 1;
                v.status     = 1;

                this.db.vouchers.Add(v);
                this.db.SaveChanges();

                message = "SUCCESS";
            }



            return(Json(new { Message = message }, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public JsonResult deleteVoucher(VoucherForm voucherForm)
        {
            string message = "";

            System.Diagnostics.Debug.WriteLine("voucher id " + voucherForm.VoucherId);
            if (voucherForm.VoucherId != 0)
            {
                try
                {
                    voucher v = db.vouchers.Find(voucherForm.VoucherId);
                    v.activeFlag      = 0;
                    db.Entry(v).State = System.Data.EntityState.Modified;
                    db.SaveChanges();
                    message = "SUCCESS";
                }
                catch (Exception e)
                {
                    message = "FAIL";
                }
            }

            return(Json(new { Message = message }, JsonRequestBehavior.AllowGet));
        }