Ejemplo n.º 1
0
        public ActionResult InsertFollowUp(FormCollection collection)
        {
            try
            {
                using (LoanDataDataContext database = new LoanDataDataContext())
                {
                    Daily_Follow_Up followUp = new Daily_Follow_Up();
                    long            cID      = 0;
                    long.TryParse(collection.Get("TrackID"), out cID);
                    followUp.Tracks_ID      = cID;
                    followUp.User_Follow    = 1;
                    followUp.Follow_Date    = DateTime.Now;
                    followUp.Follow_Action  = int.Parse(collection.Get("Follow_Action"));
                    followUp.Follow_Note    = collection.Get("Follow_Note");
                    followUp.Remainder_Date = DateTime.Parse(collection.Get("Remainder_Date"));// DateTime.ParseExact(collection.Get("Remainder_Date"), "dd/MM/yyyy", null);// DateTime.Parse();
                    followUp.Remainder_Note = collection.Get("Remainder_Note");
                    //   track.Tracking_USER = long.Parse(collection.Get("Tracking_USER"));


                    database.Daily_Follow_Ups.InsertOnSubmit(followUp);
                    database.SubmitChanges();
                }

                var jsonObj = new { Message = "Follow Up inserted suc" };
                return(Json(jsonObj));
            }
            catch (Exception ex)
            {
                var jsonObj = new { Error = ex.Message };
                return(Json(jsonObj));
            }
        }
Ejemplo n.º 2
0
        public ActionResult InsertFollowUp(FormCollection collection)
        {
            try
            {
                using (LoanDataDataContext database = new LoanDataDataContext())
                {
                    string accountid = collection.Get("ACCOUNTID");
                    var    tracks    = from tr in database.Client_Loan_Infos
                                       join cl in database.Tracks on tr.ID equals cl.ClientLoanID
                                       where tr.AccountID == accountid select cl;

                    foreach (var item in tracks)
                    {
                        Daily_Follow_Up followUp = new Daily_Follow_Up();
                        // long cID = 0;
                        //  long.TryParse(collection.Get("TrackID"), out cID);
                        // followUp.Tracks_ID = cID;
                        followUp.Tracks_ID     = item.ID;
                        followUp.User_Follow   = long.Parse(TGSession.ClientInfo.UID);
                        followUp.Follow_Date   = DateTime.Now;
                        followUp.Follow_Action = int.Parse(collection.Get("Follow_Action"));
                        followUp.Follow_Note   = collection.Get("Follow_Note");
                        string[] formats  = { "dd/MM/yyyy" };
                        var      dateTime = DateTime.ParseExact(collection.Get("Remainder_Date"), formats, new CultureInfo("en-US"), DateTimeStyles.None);
                        //  followUp.Remainder_Date = DateTime.Parse(collection.Get("Remainder_Date"));// DateTime.ParseExact(collection.Get("Remainder_Date"), "dd/MM/yyyy", null);// DateTime.Parse();
                        followUp.Remainder_Date = dateTime;
                        followUp.Remainder_Note = collection.Get("Remainder_Note");
                        //   track.Tracking_USER = long.Parse(collection.Get("Tracking_USER"));


                        database.Daily_Follow_Ups.InsertOnSubmit(followUp);
                        database.SubmitChanges();
                    }
                    //  Daily_Follow_Up followUp = new Daily_Follow_Up();
                    //  long cID = 0;
                    //  long.TryParse(collection.Get("TrackID"), out cID);
                    //  followUp.Tracks_ID = cID;
                    //  followUp.User_Follow = long.Parse(TGSession.ClientInfo.UID);
                    //  followUp.Follow_Date = DateTime.Now;
                    //  followUp.Follow_Action = int.Parse(collection.Get("Follow_Action"));
                    //  followUp.Follow_Note = collection.Get("Follow_Note");
                    //  string[] formats = { "dd/MM/yyyy" };
                    //  var dateTime = DateTime.ParseExact(collection.Get("Remainder_Date"), formats, new CultureInfo("en-US"), DateTimeStyles.None);
                    ////  followUp.Remainder_Date = DateTime.Parse(collection.Get("Remainder_Date"));// DateTime.ParseExact(collection.Get("Remainder_Date"), "dd/MM/yyyy", null);// DateTime.Parse();
                    //  followUp.Remainder_Date = dateTime;
                    //  followUp.Remainder_Note = collection.Get("Remainder_Note");
                    //  //   track.Tracking_USER = long.Parse(collection.Get("Tracking_USER"));


                    //  database.Daily_Follow_Ups.InsertOnSubmit(followUp);
                    //  database.SubmitChanges();
                }

                var jsonObj = new { Message = "Follow Up inserted suc" };
                return(Json(jsonObj));
            }
            catch (Exception ex)
            {
                var jsonObj = new { Error = ex.Message };
                return(Json(jsonObj));
            }
        }
Ejemplo n.º 3
0
        public ActionResult GetTrackingForRCurrentRo(string accountId)
        {
            try
            {
               
                using (LoanDataDataContext database = new LoanDataDataContext())
                {
                    //var currentUser = database.Sys_Users.FirstOrDefault(x => x.user_name ==TGSession.ClientInfo.UserName);
                    //long id = currentUser.id;
                    var loan = (from d in database.Tracks

                                join cl in database.Client_Loan_Infos on d.ClientLoanID equals cl.ID
                                join li in database.Loan_Infos on cl.LoanID equals li.ID
                                join c in database.Sys_Users on d.CurrTraker equals c.id
                                where cl.AccountID == accountId

                                select new
                                {
                                    ID = d.ID,

                                    Client_Loan_Info = cl,
                                    Loan_Info = li,
                                    last_tracking_date = database.Daily_Follow_Ups.OrderByDescending(lt => lt.ID).FirstOrDefault(f => f.Tracks_ID == d.ID),
                                    tracks = d,
                                    Ro = c,
                                    //No_Calls = database.Daily_Follow_Ups.Where(f => f.Follow_Action == database.Actions.FirstOrDefault(ac => ac.ACTION_CODE == "CALL").ID).ToList().Count,
                                    //No_Visit = database.Daily_Follow_Ups.Where(f => f.Follow_Action == database.Actions.FirstOrDefault(ac => ac.ACTION_CODE == "VISIT").ID).ToList().Count
                                    No_Calls = database.Daily_Follow_Ups.Where(f => f.Tracks_ID == d.ID && f.Follow_Action == database.Actions.FirstOrDefault(ac => ac.ACTION_CODE == "CALL").ID).ToList().Count,
                                    No_Visit = database.Daily_Follow_Ups.Where(f => f.Tracks_ID == d.ID && f.Follow_Action == database.Actions.FirstOrDefault(ac => ac.ACTION_CODE == "VISIT").ID).ToList().Count

                                });

                    DataTable dt = new DataTable();
                    //Here Create Columns
                    dt.Columns.AddRange(new DataColumn[9] 
                      {
                          new DataColumn("RO Code", typeof(string)),
                      new DataColumn("RO name", typeof(string)),
                      new DataColumn("Client ID",typeof(string)), 
                       new DataColumn("Latest tracking date",typeof(string)), 
                        new DataColumn("Follow up date",typeof(string)), 
                         new DataColumn("Last Action",typeof(string)), 
                          new DataColumn("Reschedule",typeof(string)), 
                           new DataColumn("No. of Calls",typeof(string)), 
                            new DataColumn("Visit",typeof(string))
                          
                      });

                    //Here Insert Row
                    foreach (var item in loan)
                    {
                        string status = database.Status.FirstOrDefault(s => s.ID == item.tracks.Status) != null ? database.Status.FirstOrDefault(s => s.ID == item.tracks.Status).Name : "No Status";
                        Daily_Follow_Up dil = item.last_tracking_date;
                        string last_date = dil != null ? dil.Follow_Date.Value.ToShortDateString() : "";
                        //  string action= (from a in database.Actions where a.ID==item.last_tracking_date.Follow_Action select a).FirstOrDefault().Name;
                        dt.Rows.Add(item.Ro.RO_Code, item.Ro.RO_Name, item.Loan_Info.AccountID, item.tracks.Tracking_Date, last_date, status, item.Client_Loan_Info.Scheduled, item.No_Calls, item.No_Visit);

                    }

                    //Exporting to Excel
                    string folderPath = Server.MapPath("~/FileUploaded/Report");
                    if (!Directory.Exists(folderPath))
                    {
                        Directory.CreateDirectory(folderPath);
                    }
                    //Codes for the Closed XML
                    using (XLWorkbook wb = new XLWorkbook())
                    {
                        wb.Worksheets.Add(dt, "Tracking");

                        //wb.SaveAs(folderPath + "DataGridViewExport.xlsx");
                        string myName = Server.UrlEncode("Rep" + "_" +
                        DateTime.Now.ToString("ddMMyyyyhhmm") + ".xlsx");
                        MemoryStream stream = GetStream(wb);// The method is defined below
                        Response.Clear();
                        Response.Buffer = true;
                        Response.AddHeader("content-disposition",
                        "attachment; filename=" + myName);
                        Response.ContentType = "application/vnd.ms-excel";
                        Response.BinaryWrite(stream.ToArray());
                        Response.End();
                    }




                }

                var jsonObj = new { Message = "Report Generated" };
                return Json(jsonObj, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {

                var jsonObj = new { Error = ex.Message };
                return Json(jsonObj, JsonRequestBehavior.AllowGet);
            }
        }