Пример #1
0
 private void gvStreetLightFees_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (e.ColumnIndex == 5)
         {
             //Delete
             DialogResult result = MessageBox.Show(this, "Are you sure  to delete?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
             if (result.Equals(DialogResult.OK))
             {
                 DataGridViewRow row            = gvStreetLightFees.Rows[e.RowIndex];
                 StreetLightFee  griddata       = (StreetLightFee)row.DataBoundItem;//get the selected row's data
                 StreetLightFee  streetLightFee = mbmsEntities.StreetLightFees.Where(x => x.Active == true && x.StreetLightFeesID == griddata.StreetLightFeesID).SingleOrDefault();
                 streetLightFee.Active        = false;
                 streetLightFee.UpdatedDate   = DateTime.Now;
                 streetLightFee.UpdatedUserID = this.UserID;
                 mbmsEntities.SaveChanges();
                 MessageBox.Show("Successfully Deleted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 bindStreetLightFeesGridView();
             }
         }
         else if (e.ColumnIndex == 4)
         {
             //Edit
             DataGridViewRow row            = gvStreetLightFees.Rows[e.RowIndex];
             StreetLightFee  streetLightFee = (StreetLightFee)row.DataBoundItem;//get the selected row's data
             streetLightFeesId         = streetLightFee.StreetLightFeesID;
             cboQuarterName.Text       = streetLightFee.Quarter.QuarterNameInEng;
             cboTownshipName.Text      = streetLightFee.Quarter.Township.TownshipNameInEng;
             txtstreetlightfeeamt.Text = streetLightFee.Amount.ToString();
             btnSave.Text = "Update";
         }
     }
 }
Пример #2
0
        private bool IsBillCalculateSuccess(List <MBMS.DAL.MeterUnitCollect> dataList, DateTime fromDate, DateTime toDate)
        {
            List <MeterBill> meterbillList = new List <MeterBill>();

            try {
                foreach (MBMS.DAL.MeterUnitCollect item in dataList)
                {
                    MeterBill mb = new MeterBill();
                    mb.MeterBillID      = Guid.NewGuid().ToString();
                    mb.MeterBillCode    = item.Customer.Meter.MeterNo;
                    mb.InvoiceDate      = item.FromDate;
                    mb.LastBillPaidDate = item.ToDate;
                    mb.ServicesFees     = 0;
                    //getting multiplier value from customer's meter  value
                    meterMultiplier = (int)item.Customer.Meter.Multiplier;
                    mb.MeterFees    = getMeterFeesAmountwith7LayerCode(item);
                    StreetLightFee streetLightFeeEntity = mbmsEntities.StreetLightFees.Where(x => x.Active == true && x.QuarterID == item.Customer.QuarterID).SingleOrDefault();
                    if (streetLightFeeEntity == null)
                    {
                        mb.StreetLightFees = Utility.SettingController.StreetLightFees;
                    }
                    else
                    {
                        mb.StreetLightFees = streetLightFeeEntity.Amount;
                    }
                    mb.HorsePowerFees = 0;
                    mb.TotalFees      = Convert.ToDecimal((mb.ServicesFees + mb.MeterFees + mb.StreetLightFees + mb.HorsePowerFees));
                    //multiply totol meter unit with multiplier value
                    mb.UsageUnit         = (item.TotalMeterUnit * meterMultiplier);
                    mb.PreviousMonthUnit = 0;
                    mb.CurrentMonthUnit  = (item.TotalMeterUnit - mb.PreviousMonthUnit);
                    //calculate advance money
                    List <AdvanceMoneyCustomer> advmoneyList = mbmsEntities.AdvanceMoneyCustomers.Where(x => x.Active == true && x.MeterBill.MeterUnitCollect.CustomerID == item.CustomerID && EntityFunctions.TruncateTime(x.ForMonth) != item.FromDate.Date).ToList();
                    decimal TotalAdvance = 0;
                    foreach (AdvanceMoneyCustomer i in advmoneyList)
                    {
                        TotalAdvance += i.AdvanceMonthAmount;
                    }
                    mb.AdvanceMoney       = TotalAdvance;
                    mb.CreditAmount       = 0;
                    mb.isPaid             = false;
                    mb.Remark             = "bill data for " + item.FromDate.ToString("MMMM");
                    mb.MeterUnitCollectID = item.MeterUnitCollectID;
                    mb.Active             = true;
                    mb.CreatedDate        = DateTime.Now;
                    mb.CreatedUserID      = UserID;
                    meterbillList.Add(mb);
                }    //end of foreach loop after adding Meter Bill List
                meterbillcalculateservice.MeterBillCalculate(meterbillList, fromDate, toDate);
            }catch (Exception ex) {
                MessageBox.Show("Error occur" + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
Пример #3
0
 private void gvStreetLightFees_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
 {
     foreach (DataGridViewRow row in gvStreetLightFees.Rows)
     {
         StreetLightFee streetLightFeesEntity = (StreetLightFee)row.DataBoundItem;
         row.Cells[0].Value = streetLightFeesEntity.StreetLightFeesID;
         row.Cells[1].Value = streetLightFeesEntity.Quarter.QuarterNameInEng;
         row.Cells[2].Value = streetLightFeesEntity.Quarter.Township.TownshipNameInEng;
         row.Cells[3].Value = streetLightFeesEntity.Amount;
     }
 }
Пример #4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (checkValidation())
     {
         string QuarterId    = cboQuarterName.SelectedValue.ToString();
         bool   isdataExists = mbmsEntities.StreetLightFees.Any(x => x.Active == true && x.QuarterID == QuarterId);
         if (isdataExists)
         {
             MessageBox.Show("Same Quarter data already exists!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         if (btnSave.Text.Equals("Update"))
         {
             StreetLightFee streetlightfeeentity = mbmsEntities.StreetLightFees.Where(x => x.Active == true && x.StreetLightFeesID == streetLightFeesId).SingleOrDefault();
             streetlightfeeentity.QuarterID     = QuarterId;
             streetlightfeeentity.Amount        = Convert.ToDecimal(txtstreetlightfeeamt.Text);
             streetlightfeeentity.Active        = true;
             streetlightfeeentity.UpdatedDate   = DateTime.Now;
             streetlightfeeentity.UpdatedUserID = UserID;
             mbmsEntities.StreetLightFees.AddOrUpdate(streetlightfeeentity);
             mbmsEntities.SaveChanges();
             MessageBox.Show("Successfully Updated", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             btnSave.Text = "Save";
         }
         else
         {
             StreetLightFee streetlightfeeentity = new StreetLightFee();
             streetlightfeeentity.StreetLightFeesID = Guid.NewGuid().ToString();
             streetlightfeeentity.QuarterID         = QuarterId;
             streetlightfeeentity.Amount            = Convert.ToDecimal(txtstreetlightfeeamt.Text);
             streetlightfeeentity.Active            = true;
             streetlightfeeentity.CreatedDate       = DateTime.Now;
             streetlightfeeentity.CreatedUserID     = UserID;
             mbmsEntities.StreetLightFees.Add(streetlightfeeentity);
             mbmsEntities.SaveChanges();
             MessageBox.Show("Successfully Saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         bindStreetLightFeesGridView();
     }
 }