コード例 #1
0
 /// <summary>
 /// Create a new ExtraCharge object.
 /// </summary>
 /// <param name="customerId">Initial value of the CustomerId property.</param>
 /// <param name="monthId">Initial value of the MonthId property.</param>
 /// <param name="year">Initial value of the Year property.</param>
 /// <param name="dabbawalaCharges">Initial value of the DabbawalaCharges property.</param>
 /// <param name="deliveryCharges">Initial value of the DeliveryCharges property.</param>
 public static ExtraCharge CreateExtraCharge(global::System.Int32 customerId, global::System.Int32 monthId, global::System.Int32 year, global::System.Int32 dabbawalaCharges, global::System.Int32 deliveryCharges)
 {
     ExtraCharge extraCharge = new ExtraCharge();
     extraCharge.CustomerId = customerId;
     extraCharge.MonthId = monthId;
     extraCharge.Year = year;
     extraCharge.DabbawalaCharges = dabbawalaCharges;
     extraCharge.DeliveryCharges = deliveryCharges;
     return extraCharge;
 }
コード例 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ExtraCharges EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToExtraCharges(ExtraCharge extraCharge)
 {
     base.AddObject("ExtraCharges", extraCharge);
 }
コード例 #3
0
ファイル: Bills.cs プロジェクト: BalajiIyengar/KanaksTiffins
        /// <summary>
        /// Saves/Updates this bill in the DB.
        /// </summary>
        private void saveButtonClicked()
        {
            try
            {
                Hashtable dates = getCurrentMonthDates();
                List<MonthlyBill> billForSelectedMonth = retrieveThisUsersBill(DateTime.Parse(dates["startDate"].ToString()), DateTime.Parse(dates["endDate"].ToString()));

                //This bill is being saved for the first time.
                if (billForSelectedMonth.Count == 0)
                {
                    foreach (MonthlyBill thisDate in dataGridView_billForThisMonth.DataSource as List<MonthlyBill>)
                    {
                        db.MonthlyBills.AddObject(thisDate);
                    }
                }

                int monthId = DateTime.Parse(dates["startDate"].ToString()).Month;
                int year = DateTime.Parse(dates["startDate"].ToString()).Year;

                //Save extra charges.
                ExtraCharge charges;
                try
                {
                    charges = db.ExtraCharges.Where(x => x.CustomerId == selectedCustomerId && x.MonthId == monthId && x.Year == year).First();
                }
                catch (InvalidOperationException ex)
                {
                    charges = new ExtraCharge();
                    charges.CustomerId = selectedCustomerId;
                }

                charges.MonthId = DateTime.Parse(dates["startDate"].ToString()).Month;
                charges.Year = DateTime.Parse(dates["startDate"].ToString()).Year;

                if (textBox_dabbawalaCharges.Text.Trim().Equals(""))
                {
                    charges.DabbawalaCharges = db.CustomerDetails.Where(x => x.CustomerId == selectedCustomerId && x.isDeleted.Equals("N")).FirstOrDefault().DefaultDabbawalaCharges;
                }
                else
                {
                    charges.DabbawalaCharges = Int32.Parse(textBox_dabbawalaCharges.Text);
                }

                if (textBox_deliveryCharges.Text.Trim().Equals(""))
                {
                    charges.DeliveryCharges = 0;
                }
                else
                {
                    charges.DeliveryCharges = Int32.Parse(textBox_deliveryCharges.Text);
                }

                //An entry in ExtraCharges is being made for the first time for this customer for this month.
                if (db.ExtraCharges.Where(x => x.CustomerId == selectedCustomerId && x.MonthId == charges.MonthId && x.Year == charges.Year).Count() == 0)
                {
                    db.ExtraCharges.AddObject(charges);
                }

                db.SaveChanges();

                label_billNotSaved.Visible = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occured while updating." + ex.Message + " " + ex.StackTrace, "Error");
            }
        }