public ActionResult DialogUpdateHSIP(Order_TB_Header value)
        {
            EmailJob email = new EmailJob();

            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities  db_master = new mascisEntities();
            Order_TB_Header table     = db_master.Order_TB_Header.FirstOrDefault(o => o.OrderNumber == value.OrderNumber);

            TempData["OrderNumber"]  = value.OrderNumber;
            TempData["FacilityCode"] = value.FacilityCode;
            TempData["StartDate"]    = value.StartDate;
            TempData["EndDate"]      = value.EndDate;
            value.OrderTypeId        = 2;
            value.OrderStatusId      = 1;
            value.EditedDate         = DateTime.Now;
            value.EditedBy           = new UserManagement().getCurrentuser();
            db_master.Entry(table).CurrentValues.SetValues(value);
            db_master.Entry(table).State = EntityState.Modified;
            db_master.SaveChanges();
            if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == false)
            {
                email.OrderSentToScto(value.FacilityCode, value.OrderNumber, "TB");
            }
            if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == true)
            {
                email.OrderReSentToScto(value.FacilityCode, value.OrderNumber, "TB");
            }
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
 public Boolean UpdateSAP(string order_no)
 {
     try
     {
         var x = GetRecordByKey(order_no);
         if (x != null)
         {
             x.OrderNumber = order_no;
             //x.FacilityCode = mFacilityCode;
             //x.DatePrepared = mDatePrepared;
             //x.EditedBy = new UserManagement().getCurrentuser();
             //x.EditedDate = DateTime.Now;
             //x.DateExpected = mDateExpected;
             x.OrderStatusId = 4;
             //x.OrderStatusIdChangedBy = new UserManagement().getCurrentuser();
             //x.OrderStatusIdDateChanged = DateTime.Now;
             context.Entry(x).State = EntityState.Modified;
             context.SaveChanges();
             ////SaveLog(x);
         }
         //Send Out Confirmation Notifications to the facility
         //EmailJob obx = new EmailJob();
         //if (x.OrderStatusId == 4)
         //{
         //    obx.SendEmailSAP(x.FacilityCode, x.OrderNumber);
         //}
         return(true);
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
Beispiel #3
0
        public ActionResult SaveExpectedReport(LMIS_ExpectedReport value, string fc, string productcategory, string startdate, string enddate)
        {
            DateTime sDate    = DateTime.ParseExact(startdate, "dd/MM/yyyy", null);
            DateTime eDate    = DateTime.ParseExact(enddate, "dd/MM/yyyy", null);
            int      facility = int.Parse(fc);
            int      pc       = int.Parse(productcategory);

            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities      db_master = new mascisEntities();
            LMIS_ExpectedReport table     = db_master.LMIS_ExpectedReport.FirstOrDefault(o => o.facility_code == facility && o.product_category == pc && o.start_date == sDate && o.end_date == eDate);
            ExpectedReports     obj       = new ExpectedReports();

            if (table == null)
            {
                //db.Entry(table).CurrentValues.SetValues(value);
                obj.facility_code    = facility;
                obj.product_category = pc;
                obj.start_date       = sDate;
                obj.end_date         = eDate;
                //db_master.SaveChanges();
            }
            else
            {
                //db.Entry(table).CurrentValues.SetValues(value);
                obj.facility_code            = facility;
                obj.product_category         = pc;
                obj.start_date               = sDate;
                obj.end_date                 = eDate;
                db_master.Entry(table).State = EntityState.Modified;
                context.Entry(table).CurrentValues.SetValues(table);
            }
            obj.Update();
            return(Json(value, JsonRequestBehavior.AllowGet));
            //return RedirectToAction("DataSourceRFSO");
        }
Beispiel #4
0
 public Boolean Update()
 {
     try
     {
         var x = GetRecordByKey(mOrderNumber, mID);
         if (x != null)
         {
             x.OrderNumber          = mOrderNumber;
             x.FacilityCode         = mFacilityCode;
             x.StartDate            = mStartDate;
             x.EndDate              = mEndDate;
             x.ID                   = mID;
             x.Quantity             = mQuantity;
             context.Entry(x).State = EntityState.Modified;
             context.SaveChanges();
         }
         else
         {
             Save();
         }
         return(true);
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
 public Boolean UpdateSAP(string order_no)
 {
     try
     {
         var x = GetRecordByKey(order_no);
         if (x != null)
         {
             x.OrderNumber = order_no;
             //x.FacilityCode = mFacilityCode;
             //x.DatePrepared = mDatePrepared;
             //x.EditedBy = new UserManagement().getCurrentuser();
             //x.EditedDate = DateTime.Now;
             //x.DateExpected = mDateExpected;
             x.OrderStatusId = 4;
             //x.OrderStatusIdChangedBy = new UserManagement().getCurrentuser();
             //x.OrderStatusIdDateChanged = DateTime.Now;
             context.Entry(x).State = EntityState.Modified;
             context.SaveChanges();
             ////SaveLog(x);
         }
         return(true);
     }
     catch (Exception x)
     {
         throw (x);
     }
 }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["FacilityList"] != null && Request["FacilityList"] != string.Empty)
                {
                    string facility = Request["FacilityList"].ToString();
                    model.FacilityId = System.Convert.ToInt32(facility);
                }
                if (Request["UserTypeList"] != null && Request["UserTypeList"] != string.Empty)
                {
                    string user_type = Request["UserTypeList"].ToString();
                    model.UserTypeId = System.Convert.ToInt32(user_type);
                }
                var hased = MD5Hash(model.Password);
                var user  = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email, PhoneNumber = model.PhoneNumber, Name = model.Name, UserTypeId = System.Convert.ToInt32(model.UserTypeId), FacilityId = model.FacilityId, MD5Hash = hased, LockoutEnabled = false
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                    if (Request["RolesList"] != null && Request["RolesList"] != string.Empty)
                    {
                        string user_role = Request["RolesList"].ToString();
                        model.UserRole = user_role;
                    }
                    await this.UserManager.AddToRoleAsync(user.Id, model.UserRole);

                    var contact = db.fo_contact_person.FirstOrDefault(o => o.cp_name.Trim() == model.Name.Trim());
                    if (contact != null)
                    {
                        contact.User_ID         = user.Id;
                        db.Entry(contact).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Register", "Account"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #7
0
 public ActionResult Edit([Bind(Include = "Id,Subject,Description,StartTime,EndTime,AllDay,Recurrence,RecurrenceRule,VenueCode,ParticipationInvitee,ParticipationAttendee,ExpectedOutput,Objective,ActivityClassificationId,OrganId,DirectorateId,SectorId,SourceOfFundingId,FundingTypeId,PublicHoliday,CostEstimates,MeetingType,Approved_By,Date_Approved,Added_By,Date_Added,City,ActivityImplemented,ActivityImplementedComment,ApprovedActivity,IsBlockAppointment,BlockForAll,ActivityForwarded,Organizer")] ScheduleEvent scheduleEvent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(scheduleEvent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(scheduleEvent));
 }
        public ActionResult DialogUpdateMAULT(Order_MAULT_Header value)
        {
            context.Configuration.ProxyCreationEnabled = false;
            mascisEntities     db_master = new mascisEntities();
            Order_MAULT_Header table     = db_master.Order_MAULT_Header.FirstOrDefault(o => o.OrderNumber == value.OrderNumber);

            TempData["OrderNumber"] = value.OrderNumber;
            value.OrderStatusId     = 1;
            value.ProductCategoryId = 13;
            value.EditedDate        = DateTime.Now;
            value.EditedBy          = new UserManagement().getCurrentuser();
            db_master.Entry(table).CurrentValues.SetValues(value);
            db_master.Entry(table).State = EntityState.Modified;
            db_master.SaveChanges();
            //if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == false)
            //{
            //    obx.SendEmail(value.FacilityCode, value.OrderNumber);
            //}
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DialogInsert(A_Product value /*, string testdata, string testdata2, string testdata3*/)
        {
            try
            {
                var _feedback = db.A_Product.FirstOrDefault(f => f.product_code == value.product_code);
                db.Configuration.ProxyCreationEnabled = false;

                if (_feedback == null)
                {
                    db.A_Product.Add(value);
                }
                else
                {
                    db.Entry(_feedback).CurrentValues.SetValues(value);
                    db.Entry(_feedback).State = EntityState.Modified;
                }
                if (value.Basic_Unit == 0)
                {
                    value.Basic_Unit = null;
                }
                var recsaved = db.SaveChanges();
                // msg = value.product_description + " Saved Successfully";
                return(Json(new
                {
                    msg = "Successfully added " + value.product_description,
                    JsonRequestBehavior.AllowGet
                }));
            }
            catch (Exception ex)
            {
                throw ex;
            }


            // return Json(msg, JsonRequestBehavior.AllowGet);
        }
        public ActionResult BatchUpdateSMC(string key, List <Order_SMC_SLM_Physical_Count> changed, List <Order_SMC_SLM_Physical_Count> added, List <Order_SMC_SLM_Physical_Count> deleted)
        {
            mascisEntities dbCase = new mascisEntities();

            //Performing insert operation
            if (added != null && added.Count() > 0)
            {
                foreach (var temp in added)
                {
                    string   iDate = temp.DateOfPhysicalCount.ToString();
                    DateTime oDate = DateTime.Parse(iDate);
                    temp.DateOfPhysicalCount = oDate;

                    dbCase.Order_SMC_SLM_Physical_Count.Add(temp);
                    temp.Total         = temp.Quantity_Dispensary;
                    temp.DateAdded     = DateTime.Now;
                    temp.AddedBy       = new UserManagement().getCurrentuser();
                    temp.record_status = true;
                }
            }
            dbCase.SaveChanges();

            if (changed != null && changed.Count() > 0)
            {
                foreach (var temp in changed)
                {
                    string   iDate = temp.DateOfPhysicalCount.ToString();
                    DateTime oDate = DateTime.Parse(iDate);
                    temp.DateOfPhysicalCount = oDate;

                    Order_SMC_SLM_Physical_Count old = dbCase.Order_SMC_SLM_Physical_Count.
                                                       FirstOrDefault(o => o.FacilityCode == temp.FacilityCode && o.DateOfPhysicalCount == temp.DateOfPhysicalCount && o.ProductCode == temp.ProductCode && o.BatchNo == temp.BatchNo);
                    if (old != null)
                    {
                        dbCase.Entry(old).CurrentValues.SetValues(temp);
                        temp.Total         = temp.Quantity_Dispensary;
                        temp.DateAdded     = DateTime.Now;
                        temp.AddedBy       = new UserManagement().getCurrentuser();
                        temp.record_status = true;
                    }
                    else
                    {
                        dbCase.Order_SMC_SLM_Physical_Count.Add(temp);
                        temp.Total         = temp.Quantity_Dispensary;
                        temp.DateAdded     = DateTime.Now;
                        temp.AddedBy       = new UserManagement().getCurrentuser();
                        temp.record_status = true;
                    }
                }
            }
            dbCase.SaveChanges();
            //Performing delete operation
            if (deleted != null && deleted.Count() > 0)
            {
                foreach (var temp in deleted)
                {
                    dbCase.Order_SMC_SLM_Physical_Count.Remove(dbCase.Order_SMC_SLM_Physical_Count.FirstOrDefault(o => o.FacilityCode == temp.FacilityCode && o.DateOfPhysicalCount == temp.DateOfPhysicalCount && o.ProductCode == temp.ProductCode && o.BatchNo == temp.BatchNo));
                }
            }

            dbCase.SaveChanges();
            //return RedirectToAction("BatchDataSMC");
            var data = 0;

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        //public ActionResult BatchDataKount(DataManager dataManager)
        //{
        //    IEnumerable DataSource = context.WebTemplate_ARV_PhysicalCount.ToList();
        //    DataResult result = new DataResult();
        //    result.result = DataSource;
        //    result.count = context.WebTemplate_ARV_PhysicalCount.Count();

        //    return Json(result.count, JsonRequestBehavior.AllowGet);
        //}
        public int SavePC(int FacilityCode, DateTime DateOfPhysicalCount, int product_code, string BatchNo,
                          string Quantity_Dispensary, string Quantity_Store, DateTime?ExpiryDate, string Total, string Comment)
        {
            order_hiv_rapid_test_kit_PhysicalCount obj = new order_hiv_rapid_test_kit_PhysicalCount();
            int recstat = 0;

            obj.FacilityCode        = FacilityCode;
            obj.DateOfPhysicalCount = DateOfPhysicalCount;
            obj.product_code        = System.Convert.ToInt32(product_code);
            obj.BatchNo             = BatchNo;
            if (Quantity_Dispensary != null && !string.IsNullOrEmpty(Quantity_Dispensary))
            {
                obj.Quantity_Dispensary = System.Convert.ToDouble(Quantity_Dispensary);
            }
            if (Quantity_Store != null && !string.IsNullOrEmpty(Quantity_Store))
            {
                obj.Quantity_Store = System.Convert.ToDouble(Quantity_Store);
            }
            obj.ExpiryDate = ExpiryDate;
            if (Total != null && !string.IsNullOrEmpty(Total))
            {
                obj.Total = System.Convert.ToDouble(Total);
            }
            obj.Comment = Comment;

            try
            {
                //Check for the existance of the record
                var ca = context.order_hiv_rapid_test_kit_PhysicalCount.FirstOrDefault(c => c.FacilityCode == FacilityCode && c.DateOfPhysicalCount == DateOfPhysicalCount && c.product_code == product_code && c.BatchNo == BatchNo);

                if (ca == null)
                {
                    context.order_hiv_rapid_test_kit_PhysicalCount.Add(obj);
                    obj.DateAdded = DateTime.Now;
                    obj.AddedBy   = new UserManagement().getCurrentuser();
                    recstat       = context.SaveChanges();
                    // recstat = obj.household_number;
                }
                else
                {
                    order_hiv_rapid_test_kit_PhysicalCount table = context.order_hiv_rapid_test_kit_PhysicalCount.FirstOrDefault(c => c.FacilityCode == FacilityCode && c.DateOfPhysicalCount == DateOfPhysicalCount && c.product_code == product_code && c.BatchNo == BatchNo);
                    // obj.household_number = ca.household_number ;
                    context.Entry(table).CurrentValues.SetValues(obj);
                    obj.DateAdded = DateTime.Now;
                    obj.AddedBy   = new UserManagement().getCurrentuser();
                    context.Entry(table).State = EntityState.Modified;
                    recstat = context.SaveChanges();
                    //recstat = ca.household_number;
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }

            return(recstat);
        }
        public ActionResult SaveScto(string scto, string Telephone, string Tel, string email, string userid, int _type)
        {
            var result = string.Empty;

            if (_type == 1)
            {
                if (string.IsNullOrEmpty(scto))
                {
                    result = "Please type in the scto";
                }
                else
                {
                    var userexits = db.fo_SCTO_ContactPerson.FirstOrDefault(e => e.SCTO == scto);
                    if (userexits == null)
                    {
                        var _userid = db.fo_SCTO_ContactPerson.FirstOrDefault(e => e.UserId == userid);
                        if (_userid == null)
                        {
                            fo_SCTO_ContactPerson person = new fo_SCTO_ContactPerson();
                            person.SCTO        = scto;
                            person.SCTO_Email  = email;
                            person.SCTO_TelNo1 = Telephone;
                            person.SCTO_TelNo2 = Tel;
                            person.UserId      = userid;
                            db.fo_SCTO_ContactPerson.Add(person);
                            try
                            {
                                db.SaveChanges();
                                result = scto + " Was saved successfully";
                            }
                            catch (Exception ex)
                            {
                                result = ex.Message.ToString();
                            }
                        }
                        else
                        {
                            result = "This user was already saved as " + _userid.SCTO;
                        }
                    }
                    else
                    {
                        result = "This SCTO name already exists";
                    }
                }
            }
            else if (_type == 2)
            {
                var userexits = db.fo_SCTO_ContactPerson.FirstOrDefault(e => e.SCTO == scto);
                if (userexits != null)
                {
                    fo_SCTO_ContactPerson person = new fo_SCTO_ContactPerson();
                    person.SCTO        = scto;
                    person.SCTO_Email  = email;
                    person.SCTO_TelNo1 = Telephone;
                    person.SCTO_TelNo2 = Tel;
                    person.UserId      = userid;
                    try
                    {
                        db.Entry(userexits).CurrentValues.SetValues(person);
                        db.Entry(userexits).State = EntityState.Modified;
                        db.SaveChanges();
                        result = scto + " was updated successfully";
                    }
                    catch (Exception ex)
                    {
                        result = ex.Message.ToString();
                    }
                }
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }