Beispiel #1
0
 private void loaddata()
 {
     if (Session["hui_mod"] == null)
     {
         Maticsoft.Common.MessageBox.ShowAndRedirect(this, "没有数据,请核实", "add.aspx");
     }
     else
     {
         Maticsoft.Model.hui_kuan_dan hui_mod = new Model.hui_kuan_dan();
         hui_mod = (Maticsoft.Model.hui_kuan_dan)Session["hui_mod"];
         huikuan_neirong.Text   = hui_mod.huikuan_neirong;
         xiangmu_mingcheng.Text = hui_mod.xiangmu_mingcheng;
         xiangmu_zongkuan.Text  = string.Format("{0:F}", hui_mod.xiangmu_zongkuan);
         yifu_jine.Text         = hui_mod.yifu_jine.ToString();
         zhifu_shijian.Text     = hui_mod.zhifu_shijian.ToString();
         benci_jine.Text        = string.Format("{0:F}", hui_mod.benci_jine);
         yuji_yukuan.Text       = hui_mod.yuji_yukuan.ToString();
         int supplier_id = Convert.ToInt16(hui_mod.supplier_id);
         Maticsoft.Model.supplier sup_mod = new Model.supplier();
         Maticsoft.BLL.supplier   sup_bll = new BLL.supplier();
         sup_mod        = sup_bll.GetModel(supplier_id);
         name.Text      = sup_mod.name;
         bank.Text      = sup_mod.bank;
         bank_num.Text  = sup_mod.bank_num;
         date_time.Text = DateTime.Today.ToShortDateString();
         RMB.Text       = Maticsoft.Common.Rmb.CmycurD(Convert.ToDecimal(hui_mod.benci_jine));
     }
 }
Beispiel #2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            var suppliername = selectedSupplierName;

            using (var dbCtx = new POSApplication.Model.posdbEntities())
            {
                var item = dbCtx.suppliers.SingleOrDefault(x => x.SupplierName == suppliername);
                if (item != null && suppliername.CompareTo(item.SupplierName) == 0)
                {
                    supplier c = (from x in dbCtx.suppliers
                                  where x.SupplierName == suppliername
                                  select x).First();
                    c.SupplierName    = SupplierNameField.Text;
                    c.SupplierAddress = SupplierAddressField.Text;
                    c.ContactName     = ContactPersonNameField.Text;
                    c.ContactNumber   = ContactPersonNumberField.Text;
                    dbCtx.SaveChanges();
                    MessageBox.Show("Changes Updated Successfully.");
                }
                else if (item == null)
                {
                    supplier c = (from x in dbCtx.suppliers
                                  where x.SupplierName == SupplierNameField.Text
                                  select x).SingleOrDefault();
                    if (c == null)
                    {
                        if (SupplierNameField.Text.Length > 0 && ContactPersonNameField.Text.Length > 0)
                        {
                            var r = new Model.supplier
                            {
                                SupplierName    = SupplierNameField.Text,
                                ContactName     = ContactPersonNameField.Text,
                                ContactNumber   = ContactPersonNumberField.Text,
                                SupplierAddress = SupplierAddressField.Text
                            };
                            dbCtx.suppliers.Add(r);
                            // call SaveChanges method to save student into database
                            dbCtx.SaveChanges();
                            MessageBox.Show("New Supplier " + SupplierNameField.Text + " Added.");
                            SuccessfulSupplierAddition();
                        }
                        else
                        {
                            MessageBox.Show("Please enter New supplier name and contact person name.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Supplier with the same name already exists.");
                    }
                }
            }

            LoadExistingSuppliers();
        }