Beispiel #1
0
        public static string EditHoarding(string ID)
        {
            HoardingHistory hoardingHistory = new HoardingHistory();
            Hoarding        hoarding        = new Hoarding();
            UserDetail      result          = new UserDetail();
            int             HoardingID      = Convert.ToInt32(ID);

            try
            {
                hoardingHistory = Global.dc.HoardingHistories.FirstOrDefault(i => i.HoadingHistoryID == HoardingID && i.IsActive == true && (!i.IsDeleted.Value || !i.IsDeleted.HasValue));
                if (hoardingHistory != null)
                {
                    //hoarding.Amount = hoardingHistory.Amount;
                    //hoarding.FromDate = hoardingHistory.FromDate;
                    //hoarding.ToDate = hoardingHistory.ToDate;
                    //hoarding.CityID = hoardingHistory.City;
                    //hoarding.AreaID = hoardingHistory.Area;
                    //hoarding.AreaName = hoardingHistory.AreaDetail.Area;

                    //hoarding.CityName = hoardingHistory.CityDetail.CityName;
                    //hoarding.HoardingBanner = hoardingHistory.BannerName;
                    //hoarding.UserID = hoardingHistory.HoardingDetail.UserID;
                    //hoarding.HoardingNo = hoardingHistory.HoardingNo;
                    //hoarding.HoardingID = hoardingHistory.HoardingID;
                    //hoarding.Username = hoardingHistory.HoardingDetail.UserDetail.PersonName;
                    //hoarding.ID = hoardingHistory.HoadingHistoryID;
                }
            }
            catch (Exception)
            {
            }
            return(new JavaScriptSerializer().Serialize(hoarding));
        }
Beispiel #2
0
        public static string DeleteHoarding(string ID)
        {
            string result = string.Empty;

            try
            {
                int HoardingID = Convert.ToInt32(ID);


                //Remove hoarding history details
                HoardingHistory hoardingHistory = Global.dc.HoardingHistories.FirstOrDefault(i => i.HoadingHistoryID == HoardingID && i.IsActive == true && (!i.IsDeleted.Value || !i.IsDeleted.HasValue));
                if (hoardingHistory != null)
                {
                    hoardingHistory.IsDeleted = true;
                    int count = Global.dc.SaveChanges();
                    if (count > 0)
                    {
                        //HoardingDetail hoarding = Global.dc.HoardingDetails.FirstOrDefault(i => i.HoardingID == hoardingHistory.HoardingID && i.IsActive == true && (!i.IsDeleted.Value || !i.IsDeleted.HasValue));
                        //if (hoarding != null)
                        //{
                        //    count = 0;
                        //    hoarding.IsDeleted = true;
                        //    count = Global.dc.SaveChanges();
                        //    result = count.ToString();
                        //}
                        //else
                        //{
                        //    result = "3";
                        //}
                    }
                    else
                    {
                        result = "2";
                    }
                    result = Convert.ToString(count);
                }
                else
                {
                    result = "3";
                }
            }
            catch (Exception)
            {
                result = "-1";
            }
            return(result);
        }
Beispiel #3
0
        public static string UpdateHoarding(string ID, string HoardingNo, string User, string Area, string City, string FromDate, string ToDate, string Amount, string FileName)
        {
            // result 0 for not saved
            // result -1 for some internal error
            // result 1 or greater than 1 for successfuly saved
            string result = "0";

            UserDetail      user              = new UserDetail();
            HoardingHistory hoarding          = new HoardingHistory();
            int             HoardingHistoryID = Convert.ToInt32(ID);

            try
            {
                hoarding = Global.dc.HoardingHistories.FirstOrDefault(i => i.IsActive == true && (!i.IsDeleted.Value || !i.IsDeleted.HasValue) && i.HoadingHistoryID == HoardingHistoryID);

                if (hoarding != null)
                {
                    //hoarding.HoardingNo = HoardingNo;
                    //hoarding.Area = Convert.ToInt32(Area);
                    //hoarding.City = Convert.ToInt32(City);
                    //hoarding.FromDate = DateTime.ParseExact(FromDate, "dd/MM/yyyy", null);
                    //hoarding.ToDate = DateTime.ParseExact(ToDate, "dd/MM/yyyy", null);
                    //hoarding.Amount = Convert.ToDecimal(Amount);
                    //if (!string.IsNullOrEmpty(FileName))
                    //{
                    //    hoarding.BannerName = FileName;
                    //}
                    //int count = Global.dc.SaveChanges();
                    // result = count.ToString();
                }
                else
                {
                    result = "3";
                }
            }
            catch (Exception)
            {
                result = "-1";
            }
            return(result);
        }
        protected void btnHoardingEntry_Click(object sender, EventArgs e)
        {
            HoardingHistory hoardingHistory = new HoardingHistory();
            string          originalFilename = string.Empty, replaceFilename = string.Empty;
            string          accounType = string.Empty;
            DateTime        fromDate, ToDate;

            try
            {
                fromDate = DateTime.Parse(txtFromDate.Text);
                ToDate   = DateTime.Parse(txtToDate.Text);

                accounType = Request.Form["ddlAccountType"];

                if (accounType.ToLower() == "permanent")
                {
                    var result = Global.dc.CheckPermanentEntry(fromDate, ToDate, accounType.ToLower(), Convert.ToInt32(hdnHoardingMasterID.Value)).FirstOrDefault();


                    if (result != null)
                    {
                        Response.Write("<script>alert('Hoarding Entry Already Exist ');</script>");
                    }
                    else
                    {
                        #region Insert New Entry

                        //                        int hoardingID = Global.dc.HoardingHistories.Max(i => i.HoadingHistoryID) + 1;
                        //                      hoarding.HoardingID = hoardingID;
                        hoardingHistory.UserID           = Convert.ToInt32(Request.Form["hdnParty"]);
                        hoardingHistory.HoardingMasterID = Convert.ToInt32(Request.Form["hdnHoardingMasterID"]);
                        hoardingHistory.IsActive         = true;
                        hoardingHistory.IsDeleted        = false;
                        hoardingHistory.FromDate         = fromDate;
                        hoardingHistory.ToDate           = ToDate;
                        hoardingHistory.Type             = accounType.ToLower();
                        hoardingHistory.Amount           = Convert.ToDecimal(txtMonthlyAmount.Text);


                        string path = "/Images/HoardingImage/";

                        DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath(path));

                        if (!dirInfo.Exists)
                        {
                            DirectoryInfo dir = Directory.CreateDirectory(Server.MapPath(path));
                        }

                        if (fileHoardingImage.HasFile)
                        {
                            if (!Directory.Exists(path))
                            {
                                originalFilename = fileHoardingImage.FileName;
                                replaceFilename  = GetTimeStamp() + Path.GetExtension(originalFilename);
                                fileHoardingImage.SaveAs(Server.MapPath(path) + replaceFilename);
                            }
                        }
                        //Set image file name in database

                        hoardingHistory.BannerName = replaceFilename;

                        if (accounType.ToLower() == "permanent")
                        {
                            hoardingHistory.IsPermanent = true;
                        }
                        else if (accounType.ToLower() == "temporary")
                        {
                            hoardingHistory.IsPermanent = false;
                        }
                        hoardingHistory.CreatedDate = DateTime.Now;

                        Global.dc.HoardingHistories.Add(hoardingHistory);
                        int count = Global.dc.SaveChanges();
                        if (count > 0)
                        {
                            Response.Write("<script>alert('Hoarding Entry done successfully.');</script>");
                        }
                        else
                        {
                            //Record insertion failed
                            Response.Write("<script>alert('Some  Internal problem');</script>");
                        }

                        #endregion
                    }
                }
                else if (accounType.ToLower() == "temporary")
                {
                    var result = Global.dc.CheckTemporaryEntry(fromDate, ToDate, accounType.ToLower(), Convert.ToInt32(hdnHoardingMasterID.Value)).ToList();
                    if (result != null)
                    {
                        Response.Write("<script>alert('Temporary Hoarding Entry Already Exist ');</script>");
                    }
                    else
                    {
                        #region Insert New Entry

                        //                        int hoardingID = Global.dc.HoardingHistories.Max(i => i.HoadingHistoryID) + 1;
                        //                      hoarding.HoardingID = hoardingID;
                        hoardingHistory.UserID           = Convert.ToInt32(Request.Form["hdnParty"]);
                        hoardingHistory.HoardingMasterID = Convert.ToInt32(Request.Form["hdnHoardingMasterID"]);
                        hoardingHistory.IsActive         = true;
                        hoardingHistory.IsDeleted        = false;
                        hoardingHistory.FromDate         = fromDate;
                        hoardingHistory.ToDate           = ToDate;
                        hoardingHistory.Type             = accounType.ToLower();
                        hoardingHistory.Amount           = Convert.ToDecimal(txtMonthlyAmount.Text);


                        string path = "/Images/HoardingImage/";

                        DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath(path));

                        if (!dirInfo.Exists)
                        {
                            DirectoryInfo dir = Directory.CreateDirectory(Server.MapPath(path));
                        }

                        if (fileHoardingImage.HasFile)
                        {
                            if (!Directory.Exists(path))
                            {
                                originalFilename = fileHoardingImage.FileName;
                                replaceFilename  = GetTimeStamp() + Path.GetExtension(originalFilename);
                                fileHoardingImage.SaveAs(Server.MapPath(path) + replaceFilename);
                            }
                        }
                        //Set image file name in database

                        hoardingHistory.BannerName = replaceFilename;

                        if (accounType.ToLower() == "permanent")
                        {
                            hoardingHistory.IsPermanent = true;
                        }
                        else if (accounType.ToLower() == "temporary")
                        {
                            hoardingHistory.IsPermanent = false;
                        }
                        hoardingHistory.CreatedDate = DateTime.Now;

                        Global.dc.HoardingHistories.Add(hoardingHistory);
                        int count = Global.dc.SaveChanges();
                        if (count > 0)
                        {
                            Response.Write("<script>alert('Hoarding Entry done successfully.');</script>");
                        }
                        else
                        {
                            //Record insertion failed
                            Response.Write("<script>alert('Some  Internal problem');</script>");
                        }

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('Some  Internal problem');</script>");
            }
        }
Beispiel #5
0
        public string RenewHoarding(string ID)
        {
            string result = string.Empty;
            int    count  = 0;

            try
            {
                int      HoardingID = Convert.ToInt32(ID);
                DateTime toDate;
                //Cascade check in hoarding history table
                var hoarding = Global.dc.HoardingHistories.FirstOrDefault(i => i.IsActive == true && (!i.IsDeleted.HasValue || !i.IsDeleted.Value) && (!i.IsExpired.HasValue || !i.IsExpired.Value) && i.HoadingHistoryID == HoardingID);
                //if not null also needs to check for todate value is greater than current date or not
                if (hoarding != null && hoarding.ToDate > DateTime.Now.Date)
                {
                    //if hoarding is not null update record for expire and if successfully expired then renew this hoarding
                    hoarding.IsExpired   = true;
                    toDate               = hoarding.ToDate.Value;
                    hoarding.ToDate      = DateTime.Now.Date;
                    hoarding.UpdatedDate = DateTime.Now;

                    count = Global.dc.SaveChanges();
                    if (count > 0)
                    {
                        HoardingHistory renewHoarding = new HoardingHistory();
                        renewHoarding.UserID           = hoarding.UserID;
                        renewHoarding.HoardingMasterID = hoarding.HoardingMasterID;
                        renewHoarding.IsPermanent      = hoarding.IsPermanent;
                        renewHoarding.Status           = hoarding.Status;
                        renewHoarding.Type             = hoarding.Type;
                        renewHoarding.FromDate         = DateTime.Now.Date;
                        renewHoarding.ToDate           = toDate;
                        renewHoarding.Amount           = hoarding.Amount;
                        renewHoarding.BannerName       = hoarding.BannerName;
                        renewHoarding.IsActive         = true;
                        renewHoarding.IsDeleted        = false;
                        renewHoarding.IsExpired        = false;
                        renewHoarding.IsRenewed        = true;
                        renewHoarding.CreatedBy        = SessionManager.AdminID;
                        renewHoarding.CreatedDate      = DateTime.Now;

                        Global.dc.HoardingHistories.Add(renewHoarding);
                        count = 0;
                        count = Global.dc.SaveChanges();
                        if (count > 0)
                        {
                            result = Convert.ToString(count);
                        }
                        else
                        {
                            result = "0";
                        }
                    }
                    else
                    {
                        result = "0";
                    }
                }
                else
                {
                    result = "0";
                }
            }
            catch (Exception)
            {
                result = "-1";
            }
            return(result);
        }
Beispiel #6
0
        protected void btnHoardingEntry_Click(object sender, EventArgs e)
        {
            HoardingHistory hoardingHistory = new HoardingHistory();
            string          originalFilename = string.Empty, replaceFilename = string.Empty;
            string          accounType = string.Empty;
            DateTime        fromDate, ToDate;

            try
            {
                #region Date time conversion

                fromDate = DateTime.ParseExact(Request.Form["hdnFromDate"], "MM/dd/yy", CultureInfo.InvariantCulture);
                ToDate   = DateTime.ParseExact(Request.Form["hdnToDate"], "MM/dd/yy", CultureInfo.InvariantCulture);


                #endregion


                //ToDate = DateTime.Parse(txtToDate.Text);

                accounType = Request.Form["ddlAccountType"];
                int hoardingMasterID = Convert.ToInt32(hdnHoardingMasterID.Value);
                int DayCount         = Convert.ToInt32(txtDayOrMonth.Text);

                if (accounType.ToLower() == "permanent")
                {
                    var result = Global.dc.CheckPermanentEntry(fromDate, ToDate, accounType.ToLower(), Convert.ToInt32(hdnHoardingMasterID.Value)).FirstOrDefault();


                    if (result != null)
                    {
                        Response.Write("<script>alert('Hoarding Entry Already Exist ');</script>");
                    }
                    else
                    {
                        #region Insert New Permanent Entry

                        //                        int hoardingID = Global.dc.HoardingHistories.Max(i => i.HoadingHistoryID) + 1;
                        //                      hoarding.HoardingID = hoardingID;
                        hoardingHistory.UserID           = Convert.ToInt32(Request.Form["hdnParty"]);
                        hoardingHistory.HoardingMasterID = Convert.ToInt32(Request.Form["hdnHoardingMasterID"]);
                        hoardingHistory.IsActive         = true;
                        hoardingHistory.IsDeleted        = false;
                        hoardingHistory.IsPermanent      = true;
                        if (ToDate < DateTime.Now)
                        {
                            hoardingHistory.IsExpired = true;
                        }
                        else
                        {
                            hoardingHistory.IsExpired = false;
                        }

                        hoardingHistory.FromDate = fromDate;
                        hoardingHistory.ToDate   = ToDate;
                        hoardingHistory.Type     = accounType.ToLower();
                        hoardingHistory.Amount   = Convert.ToDecimal(txtMonthlyAmount.Text);

                        //set Renew value for insertion

                        if (!string.IsNullOrEmpty(hdnIsRenew.Value))
                        {
                            if (hdnIsRenew.Value.ToLower() == "true")
                            {
                                hoardingHistory.IsRenewed = true;
                            }
                            else
                            {
                                hoardingHistory.IsRenewed = false;
                            }
                        }
                        else
                        {
                            hoardingHistory.IsRenewed = false;
                        }
                        //end renew code
                        string path = ConfigurationManager.AppSettings["FolderPath"];

                        DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath(path));

                        if (!dirInfo.Exists)
                        {
                            DirectoryInfo dir = Directory.CreateDirectory(Server.MapPath(path));
                        }

                        if (fileHoardingImage.HasFile)
                        {
                            if (!Directory.Exists(path))
                            {
                                originalFilename = fileHoardingImage.FileName;
                                replaceFilename  = GetTimeStamp() + Path.GetExtension(originalFilename);
                                fileHoardingImage.SaveAs(Server.MapPath(path) + replaceFilename);


                                hoardingHistory.BannerName = replaceFilename;
                            }
                        }
                        //Set image file name in database

                        hoardingHistory.IsPermanent = true;
                        hoardingHistory.CreatedDate = DateTime.Now;

                        Global.dc.HoardingHistories.Add(hoardingHistory);
                        int count = Global.dc.SaveChanges();
                        if (count > 0)
                        {
                            Response.Write("<script>alert('Hoarding Entry done successfully.');</script>");
                        }
                        else
                        {
                            //Record insertion failed
                            Response.Write("<script>alert('Record insertion failed');</script>");
                        }

                        #endregion
                    }
                }
                else if (accounType.ToLower() == "temporary")
                {
                    var result = Global.dc.CheckTemporaryEntry(fromDate, ToDate, accounType.ToLower(), Convert.ToInt32(hdnHoardingMasterID.Value)).FirstOrDefault();
                    if (result != null)
                    {
                        Response.Write("<script>alert('Temporary Hoarding Entry Already Exist ');</script>");
                    }
                    else
                    {
                        var resultPermanentData = Global.dc.HoardingHistories.FirstOrDefault(i => i.Type.ToLower() == "permanent" && i.IsActive == true && (!i.IsDeleted.HasValue || i.IsDeleted == false) && i.HoardingMasterID == hoardingMasterID && i.FromDate <= fromDate && i.ToDate >= ToDate);

                        var hoardingEntery = Global.dc.CheckPermanentEntry(resultPermanentData.FromDate, resultPermanentData.ToDate.Value.AddDays(DayCount), resultPermanentData.Type, resultPermanentData.HoardingMasterID).FirstOrDefault();
                        if (hoardingEntery != null)
                        {
                            // if future hoarding is booked
                            Response.Write("<script>alert('Permanent Hoarding Entry Already Exist For Extend days ');</script>");
                        }
                        else
                        {
                            #region Insert New Temporary Entry

                            //                        int hoardingID = Global.dc.HoardingHistories.Max(i => i.HoadingHistoryID) + 1;
                            //                      hoarding.HoardingID = hoardingID;


                            hoardingHistory.UserID           = Convert.ToInt32(Request.Form["hdnParty"]);
                            hoardingHistory.HoardingMasterID = Convert.ToInt32(Request.Form["hdnHoardingMasterID"]);
                            hoardingHistory.IsActive         = true;
                            hoardingHistory.IsDeleted        = false;
                            hoardingHistory.FromDate         = fromDate;
                            hoardingHistory.IsPermanent      = false;

                            if (ToDate < DateTime.Now)
                            {
                                hoardingHistory.IsExpired = true;
                            }
                            else
                            {
                                hoardingHistory.IsExpired = false;
                            }

                            hoardingHistory.ToDate = ToDate;
                            hoardingHistory.Type   = accounType.ToLower();
                            hoardingHistory.Amount = Convert.ToDecimal(txtMonthlyAmount.Text);

                            //for temporary Entery Renew is not possible so set it direct to false
                            hoardingHistory.IsRenewed = false;

                            string path = ConfigurationManager.AppSettings["FolderPath"];

                            DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath(path));

                            if (!dirInfo.Exists)
                            {
                                DirectoryInfo dir = Directory.CreateDirectory(Server.MapPath(path));
                            }

                            if (fileHoardingImage.HasFile)
                            {
                                if (!Directory.Exists(path))
                                {
                                    originalFilename = fileHoardingImage.FileName;
                                    replaceFilename  = GetTimeStamp() + Path.GetExtension(originalFilename);
                                    fileHoardingImage.SaveAs(Server.MapPath(path) + replaceFilename);

                                    hoardingHistory.BannerName = replaceFilename;
                                }
                            }
                            //Set image file name in database


                            if (accounType.ToLower() == "permanent")
                            {
                                hoardingHistory.IsPermanent = true;
                            }
                            else if (accounType.ToLower() == "temporary")
                            {
                                hoardingHistory.IsPermanent = false;
                            }
                            hoardingHistory.CreatedDate = DateTime.Now;

                            Global.dc.HoardingHistories.Add(hoardingHistory);
                            int count = Global.dc.SaveChanges();
                            if (count > 0)
                            {
                                //After temporary entery save update record of permamanet entery by adding extra days to it expire date

                                //var resultData = Global.dc.CheckPermanentEntry(fromDate, ToDate, "permanent", Convert.ToInt32(hdnHoardingMasterID.Value)).FirstOrDefault();

                                var resultData = Global.dc.HoardingHistories.FirstOrDefault(i => i.Type.ToLower() == "permanent" && i.IsActive == true && (!i.IsDeleted.HasValue || i.IsDeleted == false) && i.HoardingMasterID == hoardingMasterID && i.FromDate <= fromDate && i.ToDate >= ToDate);


                                if (resultData != null)
                                {
                                    resultData.IsActive = false;
                                    resultData.ToDate   = resultData.ToDate.Value.AddDays(DayCount);
                                    var cnt = Global.dc.SaveChanges();
                                }

                                Response.Write("<script>alert('Hoarding Entry done successfully.');</script>");
                            }
                            else
                            {
                                //Record insertion failed
                                Response.Write("<script>alert('Record insertion failed');</script>");
                            }

                            #endregion
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "<script>alert('some internal problem');</script>";
                //Response.Write(ex.Message);
                hdnError.Value = ex.Message;
                Response.Write(message);
                //ClientScript.RegisterStartupScript(this.GetType(), "alert", message);
            }
        }