Esempio n. 1
0
 public void GetClientBill(ClientBill clientBill)
 {
     this.clientBill    = clientBill;
     this.ClientNameStr = clientBill.ClientName;
     this.MonthStr      = clientBill.yearAndMonth.Month + "/" + clientBill.yearAndMonth.Year;
     this.PriceStr      = clientBill.TotalBill.ToString();
 }
Esempio n. 2
0
        public ActionResult BillPament(int?id)
        {
            int ab = Convert.ToInt32(Session["id"]);
            int bc = Convert.ToInt32(Session["Designation"]);

            if (ab != 0 && bc == 1)
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                ClientBill clientbill = db.ClientBills.Find(id);
                if (clientbill == null)
                {
                    return(HttpNotFound());
                }
                // ViewBag.ClientId = new SelectList(db.ClientBills, "ClientId", "ClietName");
                ViewBag.payment = 00;
                return(View(clientbill));
            }
            else
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("Login", "Login"));
            }
        }
Esempio n. 3
0
 public BillWindow(ClientBill clientBill, YearAndMonth date)
 {
     InitializeComponent();
     viewModel   = CrmContianer.container.GetInstance <IBillViewModel>();
     DataContext = viewModel;
     viewModel.GetClientBill(clientBill);
     viewModel.GetGridFromWindow(DynamicGrid);
 }
Esempio n. 4
0
        // GET: ClientBills/Details/5
        public ActionResult Details(int?id)
        {
            ViewBag.error = id == null;

            ClientBill clientBill = db.ClientBills.Find(id);

            ViewBag.ClientError = clientBill == null;
            return(View(clientBill));
        }
Esempio n. 5
0
 public ActionResult RetentionReport(int?id)
 {
     if (id != null)
     {
         ClientBill clientbill = db.SingleOrDefault <ClientBill>("select * from ClientBill where CBillID =@0", id);
         clientbill.RetentionAmtIsPaid = true;
         base.BaseSave <ClientBill>(clientbill, true);
     }
     return(View("RetentionReport", base.BaseIndex <ClientDet>(null, " *  ", "ClientBill cb inner join Client c on cb.ClientID = c.ClientID where RetentionAmtIsPaid = '0' ")));
 }
Esempio n. 6
0
        public ActionResult NewServiceAdd(Client client, int?ServiceId, int?ScheduleTimeId, int?EmployeeId)
        {
            int er = 0;

            if (ServiceId == null)
            {
                er++;
                ViewBag.Service = "Select One Item";
            }

            if (ScheduleTimeId == null)
            {
                er++;
                ViewBag.ScheduleTime = "Select One Item";
            }
            if (EmployeeId == null)
            {
                er++;
                ViewBag.Employee = "Select One Item";
            }
            if (er > 0)
            {
                ViewBag.ServiceId      = new SelectList(db.Servicesses, "ServiceId", "ServiceName");
                ViewBag.EmployeeId     = new SelectList(db.Employees, "EmployeeId", "EmployeeName");
                ViewBag.ScheduleTimeId = new SelectList(db.ScheduleTimes, "ScheduleTimeId", "ScheduleName");
                return(View(client));
            }
            else
            {
                ClientServiceList list = new ClientServiceList();
                list.ClientId       = client.ClientId;
                list.ServiceId      = Convert.ToInt32(ServiceId);
                list.Service_Status = true;
                db.ClientServiceLists.Add(list);

                ClientBill bill = new ClientBill();
                bill.ClientId   = client.ClientId;
                bill.BillMonth  = client.ClientGymStart;
                bill.BillStatus = false;
                var serviceprice = db.Servicesses.Where(x => x.ServiceId == ServiceId).FirstOrDefault().ServieAmount;
                bill.BillAmount = Convert.ToInt16(serviceprice);
                bill.DueStatus  = 0;
                db.ClientBills.Add(bill);

                Schedule schedule = new Schedule();
                schedule.ClientId       = client.ClientId;
                schedule.EmployeeId     = Convert.ToInt32(EmployeeId);
                schedule.ScheduleTimeId = Convert.ToInt32(ScheduleTimeId);
                db.Schedules.Add(schedule);
                db.SaveChanges();
                ViewBag.Message = "Service Add Sucessful";
                return(RedirectToAction("ClientInformation"));
            }
        }
Esempio n. 7
0
        private void customerItem_Load(object sender, EventArgs e)
        {
            labelControl5.Text = ucDisplayBills.SetValueForText1;
            //SupplierBill  x = context.SupplierBills.Where(d => d.billID == int.Parse(ucDisplayBills.SetValueForText1)).FirstOrDefault();
            ClientBill xc = context.ClientBills.Find(z);

            labelControl6.Text  = (xc.billDate.ToString()).Substring(0, 10);
            labelControl16.Text = xc.Client.clientName;
            labelControl15.Text = " ";
            labelControl14.Text = xc.Client.clientPhoneNumber;

            clientBillItemBindingSource.DataSource = context.ClientBillItems.Where(v => v.billID == z).ToList();
            itemBindingSource.DataSource           = context.Items.ToList();
        }
Esempio n. 8
0
        public object Generate(ClientBill clientBill)
        {
            this.clientBill = clientBill;
            Document doc      = new Document(PageSize.A4);
            string   fileName = clientBill.ClientName + clientBill.yearAndMonth.Month + "-" + clientBill.yearAndMonth.Year + "-" + clientBill.Recepits.Count + ".pdf";
            string   folder   = (clientBill.ClientName);
            var      output   = new FileStream(MainConfigs.BaseSaveAdrressForPdf + folder + @"\" + fileName, FileMode.Create);
            var      writer   = PdfWriter.GetInstance(doc, output);

            doc.Open();
            PdfPTable table1 = createBillConstTable(clientBill);

            doc.Add(table1);
            for (int i = 0; i < clientBill.Recepits.Count; i++)
            {
                PdfPTable table2 = createLineTable(clientBill.Recepits[i]);
                doc.Add(table2);
            }
            doc.Close();
            return(doc);
        }
        private void Calculate(object obj)
        {
            List <string> Checkedlines = new List <string>();

            foreach (var item in cbObjects)
            {
                if (item.IsSelected)
                {
                    Checkedlines.Add(item.ObjectData.Number);
                }
            }
            YearAndMonth     selectedDate               = new YearAndMonth(SelectedYear, SelectedMonth);
            BillRequestModel billRequestModel           = new BillRequestModel(currentClient.ID, Checkedlines, selectedDate);
            Tuple <object, HttpStatusCode> returnTuple1 = httpClient.PostRequest(ApiConfigs.CheckIfLineExistedRoute, billRequestModel);

            if (returnTuple1.Item2 == HttpStatusCode.OK)
            {
                if ((bool)returnTuple1.Item1)
                {
                    Tuple <object, HttpStatusCode> returnTuple = httpClient.PostRequest(ApiConfigs.GetSpecficLinesBillRoute, billRequestModel);
                    if (returnTuple.Item2 == HttpStatusCode.OK)
                    {
                        JObject jObject = new JObject();
                        jObject = (JObject)returnTuple.Item1;
                        ClientBill clientBill = jObject.ToObject <ClientBill>();
                        BillWindow billWindow = new BillWindow(clientBill, selectedDate);
                        billWindow.Show();
                        CloseThisWindow();
                    }
                }
                else
                {
                    logger.Print("One or more of the selected lines didnt exist in the selected date");
                }
            }
            else
            {
                logger.Print(returnTuple1.Item2.ToString());
            }
        }
Esempio n. 10
0
        private PdfPTable createBillConstTable(ClientBill clientBill)
        {
            /////////////const data/////////////////////
            PdfPTable table = new PdfPTable(2);

            //table1.DefaultCell.Border = 0;
            table.WidthPercentage = 100;

            PdfPCell cell11 = new PdfPCell();

            cell11.Colspan = 1;
            cell11.AddElement(new Paragraph("Client Name: " + clientBill.ClientName, new Font()));
            cell11.AddElement(new Paragraph("Date: " + clientBill.yearAndMonth.Month + "/" + clientBill.yearAndMonth.Year, new Font()));
            cell11.VerticalAlignment = Element.ALIGN_LEFT;

            PdfPCell cell12 = new PdfPCell();

            cell12.AddElement(new Paragraph("Total Price: " + clientBill.TotalBill, new Font()));
            cell12.VerticalAlignment = Element.ALIGN_CENTER;

            table.AddCell(cell11);
            table.AddCell(cell12);
            return(table);
        }
Esempio n. 11
0
        public object Generate(ClientBill clientBill)
        {
            this.clientBill = clientBill;
            ExcelPackage excel = new ExcelPackage();

            excel.Workbook.Worksheets.Add("Worksheet1");
            var headerRow = new List <string[]>()
            {
                new string[] { "client name:", clientBill.ClientName, "Date:", clientBill.yearAndMonth.Month + "/" + clientBill.yearAndMonth.Month, "Total price:", clientBill.TotalBill.ToString() }
            };
            // Determine the header range (e.g. A1:D1)
            string headerRange = "A1:" + Char.ConvertFromUtf32(headerRow[0].Length + 64) + "1";
            // Target a worksheet
            var worksheet = excel.Workbook.Worksheets["Worksheet1"];

            // Popular header row data
            worksheet.Cells[headerRange].LoadFromArrays(headerRow);
            for (int i = 0; i < clientBill.Recepits.Count; i++)
            {
                List <string[]> lineChunk = createLineChunk(clientBill.Recepits[i]);
                worksheet.Cells[3, 1 + (4 * i)].LoadFromArrays(lineChunk);
            }
            return(excel);
        }
Esempio n. 12
0
        public ActionResult ClientRegistration(Client client, int?ServiceId, int?ClientIdNumber, string ClientPassword, int?EmployeeId, int?ScheduleTimeId)
        {
            int er = 0;

            if (ServiceId == null)
            {
                ViewBag.ename = "Select Service Name";
                er++;
            }
            if (ClientPassword == "")
            {
                er++;
                ViewBag.password = "******";
            }
            if (EmployeeId == null)
            {
                er++;
                ViewBag.Employee = "Select Employee Name ";
            }
            if (ScheduleTimeId == null)
            {
                er++;
                ViewBag.ScheduleTime = "Select Schedule Name ";
            }
            bool isThisIdExist = db.Clients.ToList().Exists(a => a.ClientIdNumber == client.ClientIdNumber);

            //int a = Convert.ToInt32(ClientIdNumber);
            //var idnumber = db.Clients.Where(x => x.ClientId == a).FirstOrDefault();
            if (isThisIdExist)
            {
                er++;
                ViewBag.idnumber = "This id is already here";
            }
            bool isThisUsenameExist = db.Clients.ToList().Exists(a => a.ClientUserName == client.ClientUserName);

            if (isThisUsenameExist)
            {
                er++;
                ViewBag.username = "******";
            }

            if (er > 0)
            {
                //idnumber = 0;
                ViewBag.ServiceId      = new SelectList(db.Servicesses, "ServiceId", "ServiceName");
                ViewBag.ScheduleTimeId = new SelectList(db.ScheduleTimes, "ScheduleTimeId", "ScheduleName");
                ViewBag.EmployeeId     = new SelectList(db.Employees, "EmployeeId", "EmployeeName");
                return(View());
            }
            else
            {
                if (ModelState.IsValid)
                {
                    var id = db.Clients.Max(p => p.ClientIdNumber);
                    client.ClientIdNumber = id + 1;
                    db.Clients.Add(client);

                    ClientServiceList list = new ClientServiceList();
                    list.ClientId       = client.ClientId;
                    list.ServiceId      = Convert.ToInt32(ServiceId);
                    list.Service_Status = true;
                    db.ClientServiceLists.Add(list);

                    ClientBill bill = new ClientBill();
                    bill.ClientId   = client.ClientId;
                    bill.BillMonth  = client.ClientGymStart;
                    bill.BillStatus = false;
                    var serviceprice = db.Servicesses.Where(x => x.ServiceId == ServiceId).FirstOrDefault().ServieAmount;
                    bill.BillAmount = Convert.ToInt16(serviceprice);
                    bill.DueStatus  = 0;
                    db.ClientBills.Add(bill);

                    Schedule schedule = new Schedule();
                    schedule.EmployeeId     = Convert.ToInt32(EmployeeId);
                    schedule.ScheduleTimeId = Convert.ToInt32(ScheduleTimeId);
                    schedule.ClientId       = client.ClientId;
                    db.Schedules.Add(schedule);
                    db.SaveChanges();
                    //ViewBag.Message = "Registration Sucessful";
                    TempData["Success"] = "Registration Successfully!";
                    // ViewBag.clientid = client.ClientId;
                    return(RedirectToAction(actionName: "ClientRegistrationprint", routeValues: new { id = client.ClientId }));
                    //  return RedirectToAction("ClientInformation");
                }
            }
            ViewBag.ServiceId = new SelectList(db.Servicesses, "ServiceId", "ServiceName");
            return(View());
        }
Esempio n. 13
0
 public ActionResult Manage([Bind(Include = "CBillID,ClientID,SiteID,Tdate,RetentionPerc,TaxPerc")] ClientBill cBill)
 {
     return(base.BaseSave <ClientBill>(cBill, cBill.CBillID > 0));
 }
Esempio n. 14
0
        // [HttpPost]
        public ActionResult BillCreate(string button)
        {
            int ab = Convert.ToInt32(Session["id"]);
            int bc = Convert.ToInt32(Session["Designation"]);

            if (ab != 0 && bc == 1)
            {
                System.DateTime todaydate    = new System.DateTime(System.DateTime.Today.Ticks);
                DateTime        Current_date = Convert.ToDateTime(todaydate.ToString("dd/MM/yyyy"));

                //var billdate = db.Clients.Where(y => y.ClientGymStart == date).FirstOrDefault();
                var clientinfo = db.Clients.ToList();

                List <ClientBill> list = new List <ClientBill>();
                ViewBag.list = list;
                //client = new Client();
                // TimeSpan ts = new TimeSpan();
                foreach (var gymstart in clientinfo)
                {
                    //DateTime currentdays =
                    //TimeSpan ts = new TimeSpan();
                    // ts = date.Subtract(client.ClientGymStart);

                    var    gymstartdat           = gymstart.ClientGymStart.ToShortDateString();
                    int    clientid              = gymstart.ClientId;
                    string clientname            = gymstart.ClietName;
                    var    search_active_service = db.ClientServiceLists.Where(a => a.ClientId == clientid).FirstOrDefault();
                    if (search_active_service == null)
                    {
                        continue;
                    }
                    else
                    {
                        DateTime day              = Convert.ToDateTime(gymstartdat);
                        int      i                = Convert.ToInt32((Current_date - day).TotalDays);
                        int      service_id       = search_active_service.ServiceId;
                        var      service          = db.Servicesses.Where(b => b.ServiceId == service_id).FirstOrDefault();
                        int      service_price    = service.ServieAmount;
                        int      service_day      = service.ServiceDay;
                        var      Last_client_bill = db.ClientBills.Where(c => c.ClientId == clientid).OrderByDescending(d => d.BillMonth).FirstOrDefault();



                        ClientBill clientBill = new ClientBill();
                        if (Last_client_bill == null)
                        {
                            int totaldays = i / service_day;
                            if (totaldays == 1)
                            {
                                clientBill.ClientId   = clientid;
                                clientBill.BillAmount = service_price;
                                clientBill.BillStatus = false;
                                clientBill.DueStatus  = 0;
                                clientBill.BillMonth  = Current_date;
                                db.ClientBills.Add(clientBill);
                                db.SaveChanges();
                                list.Add(clientBill);
                            }
                        }
                        else
                        {
                            DateTime last_timeBill_date = Convert.ToDateTime(Last_client_bill.BillMonth);
                            int      totaldays2         = Convert.ToInt32((Current_date - last_timeBill_date).TotalDays);
                            int      j = totaldays2 / service_day;
                            if (j == 1)
                            {
                                clientBill.ClientId   = clientid;
                                clientBill.BillAmount = service_price;
                                clientBill.BillStatus = false;
                                clientBill.DueStatus  = 0;
                                clientBill.BillMonth  = Current_date;
                                db.ClientBills.Add(clientBill);
                                db.SaveChanges();
                                list.Add(clientBill);
                            }
                        }
                    }
                }

                //return RedirectToAction("NewBill","Account");
                return(View());
            }
            else
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("Login", "Login"));
            }
        }
Esempio n. 15
0
        public ActionResult BillPament([Bind(Include = "ClientBillId,ClientId,BillMonth,BillAmount,BillStatus, DueStatus")] ClientBill clientBill, int?payment)
        {
            int bill        = Convert.ToInt32(clientBill.BillAmount);
            int due         = Convert.ToInt32(clientBill.DueStatus);
            int paymentBill = Convert.ToInt32(payment);
            int er          = 0;

            if (paymentBill == 0)
            {
                er++;
                ViewBag.paymentmessage = "Insert Payment Amount";
            }
            if (er > 0)
            {
                return(View(clientBill));
            }
            // int presentstatus = bill - paymentBill;
            // clientBill.DueStatus = presentstatus;
            int id = Convert.ToInt32(clientBill.ClientBillId);
            int i;
            var status = db.ClientBills.Where(y => y.ClientBillId == id).FirstOrDefault();

            if (status.BillStatus == false)
            {
                if (due == 0)
                {
                    if (bill >= paymentBill)
                    {
                        i = bill - paymentBill;
                        if (i == 0)
                        {
                            due = 0;
                            clientBill.DueStatus  = due;
                            clientBill.BillStatus = true;
                        }
                        else
                        {
                            due = i;
                            clientBill.DueStatus  = due;
                            clientBill.BillStatus = false;
                        }
                    }
                    else
                    {
                        ViewBag.error1 = "Payment bill must less than Current bill";
                        return(View(clientBill));
                    }
                }
                else
                {
                    //Due payment
                    if (due >= paymentBill)
                    {
                        i = due - paymentBill;
                        if (i == 0)
                        {
                            due = 0;
                            clientBill.DueStatus  = due;
                            clientBill.BillStatus = true;
                        }
                        else
                        {
                            due = i;
                            clientBill.DueStatus  = due;
                            clientBill.BillStatus = false;
                        }
                    }
                    else
                    {
                        ViewBag.error2 = "Payment bill must less than Due Status bill";
                        return(View(clientBill));
                    }
                }
            }
            else
            {
                ViewBag.Message = "This bill is already payment";
                return(View(clientBill));
            }

            ClientBillTransection transection = new ClientBillTransection();

            transection.ClientBillId    = clientBill.ClientBillId;
            transection.TransectionDate = DateTime.Now;
            transection.BillMonth       = clientBill.BillMonth;
            transection.Amount          = paymentBill;
            transection.BillStatus      = clientBill.BillStatus;
            var a = Convert.ToInt32(db.ClientBillTransections.ToList().Max(e => Convert.ToInt64(e.InvoiceNumber)));
            int h = a + 1;

            transection.InvoiceNumber = Convert.ToString(h);

            var id2 = db.ClientBillTransections.Where(x => x.ClientBillId == clientBill.ClientBillId && x.BillMonth == clientBill.BillMonth && x.BillStatus == false);

            if (id2 == null)
            {
                ViewBag.Message = "This bill is already payment";
                return(View(clientBill));
            }
            else
            {
                db.ClientBillTransections.Add(transection);
                db.Entry(status).State     = EntityState.Detached;
                db.Entry(clientBill).State = EntityState.Modified;
                db.SaveChanges();

                ViewBag.transectionid = transection.TransectionId;
                return(RedirectToAction(actionName: "PrintTransectionInfo", routeValues: new { id = transection.TransectionId }));
            }
        }