コード例 #1
0
ファイル: MainForm.cs プロジェクト: kethort/Commerce-App
        private void btnSpecialPrice_Click(object sender, EventArgs e)
        {
            int customerID = 0;

            Int32.TryParse(mskTxtCustIDSpecPrice.Text, out customerID);

            if (!dbMngr.customerExists(customerID))
            {
                string msg = "Customer does not exist. Add the customer to the \n database before editing special pricing.";
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                return;
            }

            int productID = dbMngr.getProductID(txtPartName.Text);

            if (productID < 0)
            {
                string msg = "Product does not exist. Add the product to the \n database before editing special pricing.";
                MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                return;
            }

            double specialPrice = 0.0;

            Double.TryParse(mskTextSpecialPrice.Text.Replace("$", String.Empty), out specialPrice);

            SpecialPrice obj = new SpecialPrice(customerID, productID, specialPrice);

            dbMngr.insertSpecialPrice(obj);
        }
コード例 #2
0
        public override bool Equals(object obj)
        {
            if (GetType() != obj.GetType())
            {
                return(false);
            }

            SpecialPrice pricing = obj as SpecialPrice;

            return(this.customerID == pricing.customerID && this.productID == pricing.productID && this.price == pricing.price);
        }
コード例 #3
0
 public void insertSpecialPrice(SpecialPrice specialPrice)
 {
     using (var context = new dbContext())
     {
         context.SpecialPrices.Add(specialPrice);
         try
         {
             context.SaveChanges();
         }
         catch
         {
             throw new SQLiteException();
         }
     }
 }