Esempio n. 1
0
    protected void lbtnDelete_click(object sender, CommandEventArgs e)
    {
        try
        {
            lblOperation.Text = "";

            if (!bool.Parse(Session["canEdit"].ToString()))
            {
                throw new Exception(Feedback.NoPermissions());
            }

            bool deleted = new ImagesGallery().DeleteImage(int.Parse(e.CommandArgument.ToString()));
            if (deleted)
            {
                lblOperation.Text = Feedback.DeleteSuccessfull();
                lvwImages.DataBind();
            }
            else
            {
                lblOperation.Text = Feedback.DeleteException();
            }
        }
        catch (Exception ex)
        {
            lblOperation.Text = ex.Message;
        }
    }
Esempio n. 2
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            lblOperation.Text = "";
            if (!bool.Parse(Session["canEdit"].ToString()))
            {
                throw new Exception(Feedback.NoPermissions());
            }

            bool deleted = new ImagesGallery().DeleteDistressImage(int.Parse(Request.QueryString["DistID"]));
            if (deleted)
            {
                imgPhoto.ImageUrl = "~/Uploads/" + new DistressEntry().GetDistressImage(int.Parse(Request.QueryString["DistID"]));
                lblOperation.Text = Feedback.DeleteSuccessfull();
            }
            else
            {
                lblOperation.Text = Feedback.DeleteException();
            }
        }
        catch (Exception ex)
        {
            lblOperation.Text = ex.Message;
        }
    }
Esempio n. 3
0
        public void UploadImageForGallery(HttpPostedFileBase upload)
        {
            var imgToUpload = new ImagesGallery();

            if (upload != null)
            {
                imgToUpload.Name = generalHelper.GenerateRandomNumber() + "_" + upload.FileName;
                var path = Path.Combine(HttpContext.Current.Server.MapPath("~/Content/images/Gallery"),
                                        imgToUpload.Name);
                upload.SaveAs(path);

                imgToUpload.Id             = Guid.NewGuid();
                imgToUpload.ImagePath      = path;
                imgToUpload.DateOfCreation = DateTime.Now;
            }
            db.ImagesGallery.Add(imgToUpload);
            db.SaveChanges();
        }
Esempio n. 4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (!bool.Parse(Session["canEdit"].ToString()))
            {
                throw new Exception(Feedback.NoPermissions());
            }


            if (updDistressImage.HasFile)
            {
                int secondStID = int.Parse(Request.QueryString["SecondStID"]);

                ImageFormat imageFormat = new ImageFormat(new Guid());
                FileInfo    file        = new FileInfo(updDistressImage.FileName);
                if (file.Extension.ToLower() == ".jpg" || file.Extension.ToLower() == ".jpeg")
                {
                    imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
                }
                else if (file.Extension.ToLower() == ".gif")
                {
                    imageFormat = System.Drawing.Imaging.ImageFormat.Gif;
                }
                else if (file.Extension.ToLower() == ".png")
                {
                    imageFormat = System.Drawing.Imaging.ImageFormat.Png;
                }

                string    secStTitle = "";
                DataTable dt         = new SecondaryStreets().GetSecondaryStreetInfo(secondStID);
                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    secStTitle = string.Format("{0} - {1} - {2} ", dr["REGION_NO"].ToString(), dr["SUBDISTRICT"].ToString(), dr["SECOND_ST_NO"].ToString());

                    string datetimePart     = DateTime.Now.ToString("ddMMyyyyHHmm");
                    string imageFileName    = string.Format("{0}_{1}", datetimePart, Path.GetFileName(updDistressImage.FileName));
                    string newFileNameThumb = string.Format("{0}_{2}{3}_{1}", datetimePart, Path.GetFileName(updDistressImage.FileName), dr["REGION_NO"].ToString(), dr["SECOND_ST_NO"].ToString());
                    string fullImagePath    = Server.MapPath("~/Uploads/") + imageFileName;
                    updDistressImage.SaveAs(fullImagePath);



                    using (FileStream fi = File.OpenRead(Server.MapPath("~/Uploads/") + imageFileName))
                    {
                        using (FileStream resizedImage = File.Create(Server.MapPath("~/Uploads/") + newFileNameThumb))
                        {
                            string strDatetime = File.GetCreationTime(Server.MapPath("~/Uploads/") + newFileNameThumb).ToString("dd/MM/yyyy HH:mm");
                            ImagesClass.ResizeImagePutWatermark(fi, resizedImage, imageFormat, 1600, 1200, true, secStTitle + ' ' + strDatetime);

                            resizedImage.Dispose();
                        }

                        //ImagesClass.ResizeImage(fi, resizedImage, imageFormat, 1600, 1200);
                        fi.Close();
                    }

                    File.Delete(Server.MapPath("~/Uploads/") + imageFileName);
                    bool saved = new ImagesGallery().AddImage(secondStID, newFileNameThumb, txtImageDetails.Text, RoadType.RegionSecondarySt);
                    if (saved)
                    {
                        txtImageDetails.Text = "";
                        lblOperation.Text    = Feedback.UpdateSuccessfull();
                        //gvImages.DataBind();
                        lvwImages.DataBind();
                    }
                    else
                    {
                        lblOperation.Text = Feedback.UpdateException();
                    }
                }
                else
                {
                    throw new Exception("الرجاء اختيار ملف الصورة");
                }
            }
            else
            {
                throw new Exception("الرجاء اختيار المنطقة الفرعية");
            }
        }
        catch (Exception ex)
        {
            lblOperation.Text = ex.Message;
        }
    }
    protected void btnShowReport_Click(object sender, EventArgs e)
    {
        try
        {
            lblFeedback.Text = "";
            if (radByMonth.Checked)
            {
                if (DrpDwnListMonth.SelectedValue == "-1" || RadioButtonList1.SelectedValue == string.Empty)
                {
                    lblFeedback.Text = Feedback.NoSearchBeginDate();
                }
                else
                {
                    DataTable dt;
                    lblFeedback.Text = "";

                    if (DrpDwnListMonth.SelectedValue == "0")
                    {
                        if (RadioButtonList1.SelectedValue.StartsWith("0") && RadioButtonList1.SelectedValue.Length == 2)
                        {
                            dt = new DistressSurvey().GetSurveyedAreasWithDateInterSetions(DrpDwnListMonth.SelectedValue, RadioButtonList1.SelectedValue == "00" ? null : int.Parse(RadioButtonList1.SelectedValue).ToString(), true, true, true);
                        }
                        else
                        {
                            dt = new DistressSurvey().GetSurveyedAreasWithDateRegions(DrpDwnListMonth.SelectedValue, RadioButtonList1.SelectedValue == "0" ? null : RadioButtonList1.SelectedValue, true, true);
                        }
                        //dt.Merge(dt0, true);
                    }
                    else
                    {
                        if (RadioButtonList1.SelectedValue.StartsWith("0") && RadioButtonList1.SelectedValue.Length == 2)
                        {
                            dt = new DistressSurvey().GetSurveyedAreasWithDateInterSetions(DrpDwnListMonth.SelectedValue, RadioButtonList1.SelectedValue == "00" ? null : int.Parse(RadioButtonList1.SelectedValue).ToString(), false, true, true);
                        }
                        else
                        {
                            dt = new DistressSurvey().GetSurveyedAreasWithDateRegions(DrpDwnListMonth.SelectedValue, RadioButtonList1.SelectedValue == "0" ? null : RadioButtonList1.SelectedValue, false, true);
                        }
                        //dt.Merge(dt0, true);
                    }
                    if (dt.Rows.Count > 0)
                    {
                        Session.Add("ReportData", dt);
                        Session.Add("option", RadioButtonList1.SelectedValue.StartsWith("0") && RadioButtonList1.SelectedValue.Length == 2 ? "intersectregion" : "region");
                        string url = "ViewFinishedSurveyingReport.aspx";
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                    }
                    else
                    {
                        lblFeedback.Text = Feedback.NoData();
                    }
                }
            }
            else if (radSection.Checked)
            {
                DataTable dt = new DistressSurvey().GetSurveyedAreas(RoadType.Section);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "section");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radIntersection.Checked)
            {
                DataTable dt = new DistressSurvey().GetSurveyedAreas(RoadType.Intersect);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "intersect");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radByDate.Checked)
            {
                SpecificDate();
            }
            else if (radRegionSecondary.Checked)
            {
                DataTable dt = new DistressSurvey().GetSurveyedAreas(RoadType.RegionSecondarySt);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "region");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radTrafficCounting.Checked)
            {
                //DataTable dt = new DistressSurvey().GetSurveyedAreas(MachineSurveyType.SectionTrafficCounting);
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.SectionTrafficCounting);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "traffic");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSectionPhotos.Checked)
            {
                DataTable dt = new ImagesGallery().RoadNetworkHavingPhotos(RoadType.MainStreet);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "sectionPhotos");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radRegionPhotos.Checked)
            {
                DataTable dt = new ImagesGallery().RoadNetworkHavingPhotos(RoadType.RegionSecondarySt);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "regionPhotos");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSectionQc.Checked)
            {
                DataTable dt = new QcCheck().GetRoadNetworkHavingQCheck(RoadType.Section);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "sectionQc");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radIntersectQc.Checked)
            {
                DataTable dt = new QcCheck().GetRoadNetworkHavingQCheck(RoadType.Intersect);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "intersectQc");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radRegionQc.Checked)
            {
                DataTable dt = new QcCheck().GetRoadNetworkHavingQCheck(RoadType.RegionSecondarySt);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "regionQc");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radReSurveyIntersect.Checked || radReSurveyRegions.Checked || radReSurveySections.Checked)
            {
                DataTable dt = new DistressSurvey().GetNetworkItemMustReSurvey(radReSurveySections.Checked, radReSurveyIntersect.Checked, radReSurveyRegions.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radReSurveySections.Checked ? "radReSurveySections" : (radReSurveyIntersect.Checked ? "radReSurveyIntersect" : (radReSurveyRegions.Checked ? "radReSurveyRegions" : ""))));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radNonSurveyedSections.Checked || radNonSurveyedIntersects.Checked || radNonSurveyedRegions.Checked || radClosedRegions.Checked)
            {
                DataTable dt = new DistressSurvey().GetNonSurveyedRoadNetwork(radNonSurveyedSections.Checked, radNonSurveyedIntersects.Checked, radNonSurveyedRegions.Checked,
                                                                              radNonCompleteSurveyingRegions.Checked, radClosedRegions.Checked);

                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radNonSurveyedSections.Checked ? "radNonSurveyedSections" : (radNonSurveyedIntersects.Checked ? "radNonSurveyedIntersects" : (radNonSurveyedRegions.Checked ? "radNonSurveyedRegions" : (radClosedRegions.Checked ? "radClosedRegions" : "")))));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radNonCompleteSurveyingRegions.Checked)
            {
                DataTable dt = new DistressSurvey().GetNonSurveyedRoadNetwork(radNonSurveyedSections.Checked, radNonSurveyedIntersects.Checked, radNonSurveyedRegions.Checked,
                                                                              radNonCompleteSurveyingRegions.Checked, radClosedRegions.Checked);

                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radClosedRegions.Checked ? "radClosedRegions" : "radNonCompleteSurveyingRegions"));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSurveyedSections.Checked || radSurveyedIntersects.Checked)
            {
                DataTable dt = new DistressSurvey().GetSurveyedRoadNetwork(radSurveyedSections.Checked, radSurveyedIntersects.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radSurveyedSections.Checked ? "radSurveyedSections" : (radSurveyedIntersects.Checked ? "radSurveyedIntersects" : "")));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radNonCompleteSections.Checked || radNonCompleteIntersects.Checked)
            {
                DataTable dt = new DistressSurvey().GetNonCompleteSurveyStreets(radNonCompleteIntersects.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", radNonCompleteSections.Checked ? "radNonCompleteSections" : (radNonCompleteIntersects.Checked ? "radNonCompleteIntersects" : ""));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            if (radNonSurveySectionsStreets.Checked || radNonSurveyIntersectStreets.Checked)
            {
                DataTable dt = new DistressSurvey().GetNonSurveyedStreets(radNonSurveyIntersectStreets.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", radNonSurveySectionsStreets.Checked ? "radNonSurveySectionsStreets" : (radNonSurveyIntersectStreets.Checked ? "radNonSurveyIntersectStreets" : ""));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }

            else if (radSectionNoPhotos.Checked || radIntersectNoPhotos.Checked || radRegionNoPhotos.Checked)
            {
                DataTable dt = new ImagesGallery().RoadNetworkHavingNoPhotos(radSectionNoPhotos.Checked, radIntersectNoPhotos.Checked, radRegionNoPhotos.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radSectionNoPhotos.Checked ? "radSectionNoPhotos" : (radIntersectNoPhotos.Checked ? "radIntersectNoPhotos" : (radRegionNoPhotos.Checked ? "radRegionNoPhotos" : ""))));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }

            else if (radSectionSurveyedNoPhotos.Checked || radIntersectSurveyedNoPhotos.Checked || radRegionSurveyedNoPhotos.Checked)
            {
                DataTable dt = new ImagesGallery().RoadNetworkSurveyedHavingNoPhotos(radSectionSurveyedNoPhotos.Checked, radIntersectSurveyedNoPhotos.Checked, radRegionSurveyedNoPhotos.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radSectionSurveyedNoPhotos.Checked ? "radSectionNoPhotos" : (radIntersectSurveyedNoPhotos.Checked ? "radIntersectNoPhotos" : (radRegionSurveyedNoPhotos.Checked ? "radRegionNoPhotos" : ""))));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }

            else if (radFwd.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.FWD);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radFwd");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radIriSections.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.IRI_Sections);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radIriSections");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radIntersectIri.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.IRI_Intersects);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radIntersectIri");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radGprSections.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.GPR_Sections);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radGprSections");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radGprIntersect.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.GPR_Intersects);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radGprIntersect");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSkidSections.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.SKID_Sections);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radSkidSections");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSkidIntersects.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.SKID_Intersects);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radSkidIntersects");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radRuttingSections.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.Rutting_Sections);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radRuttingSections");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radRuttingIntersects.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.Rutting_Intersects);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radRuttingIntersects");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
        }
        catch (Exception ex)
        {
            lblFeedback.Text = ex.Message;
        }
    }
Esempio n. 6
0
        public OrderControllerTest()
        {
            var option = new DbContextOptionsBuilder <DatabaseContext>()
                         .UseInMemoryDatabase(databaseName: "DefaultConnection")
                         .Options;

            _unitOfWork = new UnitOfWork(option);

            #region
            _unitOfWork.Cities.Create(new City {
                Id   = 2,
                Name = "Минск"
            }
                                      );
            _unitOfWork.Save();

            _unitOfWork.ApplicationUsers.Create();
            var user  = _unitOfWork.ApplicationUsers.GetByEmail("*****@*****.**");
            var user2 = _unitOfWork.ApplicationUsers.GetByEmail("*****@*****.**");

            _unitOfWork.Subcategories.Create(new Subcategory
            {
                Id           = 22,
                Name         = "Женская одежда",
                Points       = 15,
                CategoryName = null,
                Category     = null
            });
            _unitOfWork.Save();
            var subcategory = _unitOfWork.Subcategories.Get(22);

            var img = new ImagesGallery
            {
                Id     = 1009,
                Name   = "брюки1.jpg",
                PostId = 1007,
                Post   = null
            };
            List <ImagesGallery> imagesGalleries = new List <ImagesGallery>();
            imagesGalleries.Add(img);

            _unitOfWork.Save();

            _unitOfWork.Posts.Create(new Post
            {
                Id             = 1007,
                Name           = "Брюки",
                Description    = "Деловой стиль",
                DateCreatePost = "11.05.2019 17:42:20",
                Status         = "1",
                CityId         = 2,
                UserId         = user.Id,
                SubcategoryId  = 22,
                City           = null,
                User           = null,
                Subcategory    = subcategory,
                ImagesGallery  = imagesGalleries
            });
            _unitOfWork.Save();
            _unitOfWork.Posts.Create(new Post
            {
                Id             = 1008,
                Name           = "Брюки1",
                Description    = "Деловой стиль",
                DateCreatePost = "11.05.2019 17:42:20",
                Status         = "1",
                CityId         = 2,
                UserId         = user2.Id,
                SubcategoryId  = 22,
                City           = null,
                User           = null,
                Subcategory    = subcategory,
                ImagesGallery  = imagesGalleries
            });
            _unitOfWork.Save();
            var post  = _unitOfWork.Posts.Get(1007);
            var post2 = _unitOfWork.Posts.Get(1008);

            _unitOfWork.Orders.Create(new Order {
                Id     = 4013,
                PostId = post.Id,
                UserId = user.Id,
                Post   = post,
                User   = user
            });
            _unitOfWork.Save();
            _unitOfWork.Orders.Create(new Order
            {
                Id     = 4014,
                PostId = post2.Id,
                UserId = user2.Id,
                Post   = post,
                User   = user
            });
            _unitOfWork.Save();
            #endregion

            _imageGalleryService = new ImageGalleryService(_unitOfWork);
            _service             = new OrderService(_unitOfWork, _imageGalleryService);

            _controller = new OrderController(_service);
        }
    protected void btnShowReport_Click(object sender, EventArgs e)
    {
        try
        {
            lblFeedback.Text = "";

            if (radSection.Checked)
            {
                DataTable dt = new DistressSurvey().GetSurveyedAreas(RoadType.Section);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "section");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radIntersection.Checked)
            {
                DataTable dt = new DistressSurvey().GetSurveyedAreas(RoadType.Intersect);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "intersect");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radRegionSecondary.Checked)
            {
                DataTable dt = new DistressSurvey().GetSurveyedAreas(RoadType.RegionSecondarySt);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "region");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radTrafficCounting.Checked)
            {
                //DataTable dt = new DistressSurvey().GetSurveyedAreas(MachineSurveyType.SectionTrafficCounting);
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.SectionTrafficCounting);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "traffic");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSectionPhotos.Checked)
            {
                DataTable dt = new ImagesGallery().RoadNetworkHavingPhotos(RoadType.MainStreet);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "sectionPhotos");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radRegionPhotos.Checked)
            {
                DataTable dt = new ImagesGallery().RoadNetworkHavingPhotos(RoadType.RegionSecondarySt);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "regionPhotos");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSectionQc.Checked)
            {
                DataTable dt = new QcCheck().GetRoadNetworkHavingQCheck(RoadType.Section);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "sectionQc");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radIntersectQc.Checked)
            {
                DataTable dt = new QcCheck().GetRoadNetworkHavingQCheck(RoadType.Intersect);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "intersectQc");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radRegionQc.Checked)
            {
                DataTable dt = new QcCheck().GetRoadNetworkHavingQCheck(RoadType.RegionSecondarySt);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "regionQc");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radReSurveyIntersect.Checked || radReSurveyRegions.Checked || radReSurveySections.Checked)
            {
                DataTable dt = new DistressSurvey().GetNetworkItemMustReSurvey(radReSurveySections.Checked, radReSurveyIntersect.Checked, radReSurveyRegions.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radReSurveySections.Checked ? "radReSurveySections" : (radReSurveyIntersect.Checked ? "radReSurveyIntersect" : (radReSurveyRegions.Checked ? "radReSurveyRegions" : ""))));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radNonSurveyedSections.Checked || radNonSurveyedIntersects.Checked || radNonSurveyedRegions.Checked || radClosedRegions.Checked)
            {
                DataTable dt = new DistressSurvey().GetNonSurveyedRoadNetwork(radNonSurveyedSections.Checked, radNonSurveyedIntersects.Checked, radNonSurveyedRegions.Checked,
                                                                              radNonCompleteSurveyingRegions.Checked, radClosedRegions.Checked);

                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radNonSurveyedSections.Checked ? "radNonSurveyedSections" : (radNonSurveyedIntersects.Checked ? "radNonSurveyedIntersects" : (radNonSurveyedRegions.Checked || radClosedRegions.Checked ? "radNonSurveyedRegions" : ""))));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radNonCompleteSurveyingRegions.Checked)
            {
                DataTable dt = new DistressSurvey().GetNonSurveyedRoadNetwork(radNonSurveyedSections.Checked, radNonSurveyedIntersects.Checked, radNonSurveyedRegions.Checked,
                                                                              radNonCompleteSurveyingRegions.Checked, radClosedRegions.Checked);

                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radNonSurveyedRegions");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSurveyedSections.Checked || radSurveyedIntersects.Checked)
            {
                DataTable dt = new DistressSurvey().GetSurveyedRoadNetwork(radSurveyedSections.Checked, radSurveyedIntersects.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radSurveyedSections.Checked ? "radSurveyedSections" : (radSurveyedIntersects.Checked ? "radSurveyedIntersects" : "")));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radNonCompleteSections.Checked || radNonCompleteIntersects.Checked)
            {
                DataTable dt = new DistressSurvey().GetNonCompleteSurveyStreets(radNonCompleteIntersects.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "section");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            if (radNonSurveySectionsStreets.Checked || radNonSurveyIntersectStreets.Checked)
            {
                DataTable dt = new DistressSurvey().GetNonSurveyedStreets(radNonSurveyIntersectStreets.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "section");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }

            else if (radSectionNoPhotos.Checked || radIntersectNoPhotos.Checked || radRegionNoPhotos.Checked)
            {
                DataTable dt = new ImagesGallery().RoadNetworkHavingNoPhotos(radSectionNoPhotos.Checked, radIntersectNoPhotos.Checked, radRegionNoPhotos.Checked);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", (radSectionNoPhotos.Checked ? "radSectionNoPhotos" : (radIntersectNoPhotos.Checked ? "radIntersectNoPhotos" : (radRegionNoPhotos.Checked ? "radRegionNoPhotos" : ""))));
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }

            else if (radFwd.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.FWD);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radFwd");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radIriSections.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.IRI_Sections);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radIriSections");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radIntersectIri.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.IRI_Intersects);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radIntersectIri");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radGprSections.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.GPR_Sections);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radGprSections");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radGprIntersect.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.GPR_Intersects);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radGprIntersect");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSkidSections.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.SKID_Sections);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radSkidSections");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radSkidIntersects.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.SKID_Intersects);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radSkidIntersects");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radRuttingSections.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.Rutting_Sections);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radRuttingSections");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
            else if (radRuttingIntersects.Checked)
            {
                DataTable dt = new MachineSurveyRoadNetworkReports().GetSurveyedAreas(MachineSurveyType.Rutting_Intersects);
                if (dt.Rows.Count > 0)
                {
                    Session.Add("ReportData", dt);
                    Session.Add("option", "radRuttingIntersects");
                    string url = "ViewFinishedSurveyingReport.aspx";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RedirectScriptCoupon", "window.open('" + url + "', '_blank')", true);
                }
                else
                {
                    lblFeedback.Text = Feedback.NoData();
                }
            }
        }
        catch (Exception ex)
        {
            lblFeedback.Text = ex.Message;
        }
    }