Esempio n. 1
0
        public JsonResult AddService(ServiceTariff serviceTariff, FormCollection form)
        {
            //Redirect to the creation page
            //get id from session
            int tariff = Convert.ToInt32(form["Tariffid"]);

            if (serviceTariff != null)
            {
                // var name = _tariffService.GetCategory(serviceTariff.GroupId).Name;
                TariffCategory lst = _tariffService.GetallTariffCategory().Where(x => x.Type == 1 && x.TariffId == tariff).FirstOrDefault();

                if (lst == null)
                {
                    TariffCategory category = new TariffCategory();
                    category.Type     = 1;
                    category.Name     = "ALL";
                    category.TariffId = tariff;
                    _tariffService.AddnewCategory(category);
                    lst = category;
                }
                serviceTariff.GroupId   = lst.Id;
                serviceTariff.Groupname = "ALL";
                serviceTariff.Price     = Convert.ToDecimal(form["serviceprice"]);
                _tariffService.AddnewServiceTariff(serviceTariff);
            }

            return(Json("{result:1}", JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
 public ActionResult DeleteService(ServiceTariff tariff)
 {
     if (tariff.Id > 0)
     {
         bool response = _tariffService.DeleteServiceTariff(tariff);
     }
     return(Json("{result:1}", JsonRequestBehavior.AllowGet));
 }
Esempio n. 3
0
        public ActionResult UploadService(int id, int mode)
        {
            ServiceTariff item = _tariffService.GetServiceTariff(id);

            ViewBag.TariffID = id;
            ViewBag.Mode     = mode;
            return(PartialView("UploadServiceTariff", item));
        }
Esempio n. 4
0
        public ActionResult EditService(int id)
        {
            ServiceTariff tariff = _tariffService.GetServiceTariff(id);

            //var lst = _tariffService.GetallTariffCategory().Where(x => x.Type == 1 && x.TariffId == tariff.Id).ToList();
            //ViewBag.serviceGroup = lst;
            ViewBag.servpricestr = Convert.ToString(tariff.Price);
            return(PartialView("EditServiceTariff", tariff));
        }
Esempio n. 5
0
 public bool UpdateServiceTariff(ServiceTariff serviceTariff)
 {
     if (serviceTariff != null)
     {
         _session.Transact(session => session.Update(serviceTariff));
         return(true);
     }
     return(false);
 }
Esempio n. 6
0
 public bool AddnewServiceTariff(ServiceTariff serviceTariff)
 {
     //add new  service tariff.
     if (serviceTariff != null)
     {
         _session.Transact(session => session.Save(serviceTariff));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 7
0
        public JsonResult EditService(ServiceTariff serviceTariff, FormCollection form)
        {
            int id = Convert.ToInt32(CurrentRequestData.CurrentContext.Request["id"]);

            if (serviceTariff != null)
            {
                string name = _tariffService.GetCategory(serviceTariff.GroupId).Name;
                serviceTariff.Groupname = name.ToUpper();
                serviceTariff.Price     = Convert.ToDecimal(form["serviceprice"]);
                _tariffService.UpdateServiceTariff(serviceTariff);
            }

            return(Json("{result:1}", JsonRequestBehavior.AllowGet));
        }
        public async Task <ServiceTariffLookup> Saveservicetariff([FromBody] ServiceTariffLookup postedServiceTariff)
        {
            //if (!ModelState.IsValid)
            //    throw new ApiException("Model binding failed.", 500);
            //if (!_serviceTariffsRepo.Validate(postedServiceTariff))
            //    throw new ApiException(_serviceTariffsRepo.ErrorMessage, 500, _serviceTariffsRepo.ValidationErrors);

            //if (!await _serviceTariffsRepo.SaveAsync(postedServiceTariff))
            //    throw new ApiException(_serviceTariffsRepo.ErrorMessage);

            foreach (var tariff in postedServiceTariff.TariffId)
            {
                var serviceTariff = new ServiceTariff();
                serviceTariff.ServiceId = postedServiceTariff.ServiceId;
                serviceTariff.TariffId  = tariff;

                await _serviceTariffsRepo.SaveAsync(serviceTariff);
            }

            return(postedServiceTariff);
        }
Esempio n. 9
0
 public ObjectWithId AddTariff(ServiceTariffDTO dto)
 {
     ServiceTariff tariff = new ServiceTariff();
     tariff.SaveChanges(dto);
     return tariff;
 }
Esempio n. 10
0
        public ActionResult UploadService(FormCollection form)
        {
            if (CurrentRequestData.CurrentContext.Request.Files.Count > 0)
            {
                System.Web.HttpPostedFileBase file = CurrentRequestData.CurrentContext.Request.Files[0];
                int mode = Convert.ToInt32(form["mode"]);


                int            id  = Convert.ToInt32(form["Tariffid"]);
                TariffCategory lst = _tariffService.GetallTariffCategory().Where(x => x.Type == 1 && x.TariffId == id && x.IsDeleted == false).FirstOrDefault();

                if (lst == null)
                {
                    TariffCategory category = new TariffCategory();
                    category.Type     = 1;
                    category.Name     = "ALL";
                    category.TariffId = Convert.ToInt32(id);
                    _tariffService.AddnewCategory(category);
                    lst = category;
                }
                //the new reading using csv

                try
                {
                    using (TextReader reader = new StreamReader(file.InputStream))
                    {
                        CsvReader csv = new CsvReader(reader);
                        List <UploadTariffCSV> records = csv.GetRecords <UploadTariffCSV>().ToList();


                        foreach (UploadTariffCSV item in records)
                        {
                            ServiceTariff servicetariff = new ServiceTariff();

                            servicetariff.GroupId     = lst.Id;
                            servicetariff.Name        = item.itemname.ToUpper();
                            servicetariff.Description = item.itemname.ToUpper();
                            servicetariff.Unit        = item.unit.ToUpper();
                            servicetariff.Price       = item.price;
                            servicetariff.Groupname   = lst.Name.ToUpper();
                            servicetariff.Remark      = item.remark;

                            if (item.authorizationRequired.ToLower().Contains("y"))
                            {
                                servicetariff.PreauthorizationRequired = true;
                            }
                            else
                            {
                                servicetariff.PreauthorizationRequired = false;
                            }

                            if (mode > 0 && !string.IsNullOrEmpty(servicetariff.Name))
                            {
                                _tariffService.AddnewServiceTariff(servicetariff);
                            }
                            else
                            {
                                //do for drug
                                lst = _tariffService.GetallTariffCategory().Where(x => x.Type == 0 && x.TariffId == id).FirstOrDefault();
                                if (lst == null)
                                {
                                    TariffCategory category = new TariffCategory();
                                    category.Type     = 0;
                                    category.Name     = "ALL";
                                    category.TariffId = Convert.ToInt32(id);
                                    _tariffService.AddnewCategory(category);
                                    lst = category;
                                }
                                DrugTariff drugariff = new DrugTariff();

                                drugariff.GroupId     = lst.Id;
                                drugariff.Name        = item.itemname.ToUpper();
                                drugariff.Description = item.itemname.ToUpper();
                                drugariff.Unit        = item.unit.ToUpper();
                                drugariff.Price       = item.price;
                                drugariff.Groupname   = lst.Name.ToUpper();
                                drugariff.Remark      = item.remark;



                                if (item.authorizationRequired.ToLower().Contains("y"))
                                {
                                    drugariff.PreauthorizationRequired = true;
                                }
                                else
                                {
                                    drugariff.PreauthorizationRequired = false;
                                }

                                if (!string.IsNullOrEmpty(drugariff.Name))
                                {
                                    _tariffService.AddnewDrugTariff(drugariff);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    _pageMessageSvc.SetErrormessage("There was an error reading the CSV uploaded,kindly check the format and try again.");

                    return
                        (Redirect(
                             string.Format(
                                 _uniquePageService.GetUniquePage <TariffContentPage>().AbsoluteUrl +
                                 "?id={0}", id)));
                }
            }
            else
            {
                _pageMessageSvc.SetErrormessage("You have not uploaded any file.");

                return
                    (Redirect(CurrentRequestData.CurrentContext.Request.UrlReferrer.AbsoluteUri));
            }



            _pageMessageSvc.SetSuccessMessage("File Upload Complete.");
            return
                (Redirect(CurrentRequestData.CurrentContext.Request.UrlReferrer.AbsoluteUri));
        }
Esempio n. 11
0
        public ActionResult DeleteService(int id)
        {
            ServiceTariff item = _tariffService.GetServiceTariff(id);

            return(PartialView("DeleteService", item));
        }
Esempio n. 12
0
 public bool SaveTariff(bool isSaveNull, System.DateTime tariffDate, long docId)
 {
     string str = string.Empty;
     foreach (System.Windows.Forms.DataGridViewRow row in (System.Collections.IEnumerable) this.dgvServices.Rows)
     {
         object ob = row.Cells.get_Item("NewRateColumn").get_Value();
         decimal num = this.ObjectParseDecimal(ref ob);
         Service service = row.get_DataBoundItem() as Service;
         long lastRateId = service.LastRateId;
         if ((num == 0M) && !isSaveNull)
         {
             bool flag = false;
             foreach (System.Data.DataRow row2 in this.dtServiceTariffTypes.Rows)
             {
                 if (lastRateId == ((long) row2.get_Item("serviceTariffId")))
                 {
                     decimal num3 = (decimal) row2.get_Item("rate");
                     if ((num3 != 0M) || isSaveNull)
                     {
                         flag = true;
                     }
                 }
             }
             if (flag)
             {
                 str = str + ((long) service.Code) + ",";
             }
         }
     }
     if ((str != string.Empty) && (Messages.QuestionYesNo(this, string.Concat((string[]) new string[] { "Для услуг с кодом:", str, System.Environment.get_NewLine(), "заданы подчиненные тарифы,но не заданы сами тарифы,", System.Environment.get_NewLine(), "поэтому подчиненные тарифы для этих услуг не сохраняться,продолжить?" })) != System.Windows.Forms.DialogResult.Yes))
     {
         return false;
     }
     System.DateTime now = System.DateTime.Now;
     foreach (System.Windows.Forms.DataGridViewRow row3 in (System.Collections.IEnumerable) this.dgvServices.Rows)
     {
         object obj3 = row3.Cells.get_Item("NewRateColumn").get_Value();
         decimal num4 = this.ObjectParseDecimal(ref obj3);
         if ((num4 != 0M) || isSaveNull)
         {
             Service service2 = row3.get_DataBoundItem() as Service;
             long num5 = service2.LastRateId;
             ServiceTariff tariff = new ServiceTariff {
                 ServiceId = service2.Id,
                 FromDate = tariffDate,
                 Created = now,
                 OrgDocumentId = docId,
                 Rate = num4
             };
             tariff.SaveChanges();
             foreach (System.Data.DataRow row4 in this.dtServiceTariffTypes.Rows)
             {
                 if (num5 == ((long) row4.get_Item("serviceTariffId")))
                 {
                     decimal num6 = (decimal) row4.get_Item("rate");
                     if ((num6 != 0M) || isSaveNull)
                     {
                         new ServiceTariffType { ServiceTariffId = tariff.Id, TariffTypeId = (int) ((int) row4.get_Item("typeId")), Rate = num6 }.SaveChanges();
                     }
                 }
             }
         }
     }
     return true;
 }
Esempio n. 13
0
        public ServiceTariff GetServiceTariff(int id)
        {
            ServiceTariff servicetariff = _session.QueryOver <ServiceTariff>().Where(x => x.Id == id).SingleOrDefault();

            return(servicetariff);
        }