Exemplo n.º 1
0
    protected void radOldSurvey_CheckedChanged(object sender, EventArgs e)
    {
        try
        {
            if (radOldSurvey.Checked)
            {
                pnlDistressDetails.Visible = false;
                pnlNewSurvey.Visible       = false;
                radlOldSurveys.Visible     = true;
                radlOldSurveys.DataBind();

                lblSurveysCount.Text    = radlOldSurveys.Items.Count.ToString();
                lbtnAddDistress.Visible = (radlOldSurveys.Items.Count > 0);
                if (radlOldSurveys.Items.Count == 1)
                {
                    radlOldSurveys.SelectedValue = DistressSurvey.GetLastSecondaryStreetSurveyNumber(int.Parse(gvRegionSamples.SelectedValue.ToString())).ToString();
                    radlOldSurveys_SelectedIndexChanged(sender, e);
                    //gvDistresses.DataBind();
                }
                else if (radlOldSurveys.Items.Count > 1)
                {
                    radlOldSurveys.SelectedIndex = 0; //-1;
                }
                else
                {
                    radlOldSurveys.SelectedIndex = -1;
                }
            }
        }
        catch (Exception ex)
        {
            lblFeedback.Text = ex.Message;
        }
    }
Exemplo n.º 2
0
        public bool UpdateSecondaryStreetSampleArea(int STREET_ID, string SECOND_AR_NAME, double SECOND_ST_LENGTH, double SECOND_ST_WIDTH, string user, string NOTES)
        {
            string sql = "";

            SECOND_AR_NAME = (string.IsNullOrEmpty(SECOND_AR_NAME)) ? "NULL" : string.Format("'{0}'", SECOND_AR_NAME.Replace("'", "''"));
            NOTES          = (string.IsNullOrEmpty(NOTES)) ? "NULL" : string.Format("'{0}'", NOTES.Replace("'", "''"));

            int lastSecondaryStSurveyNum = DistressSurvey.GetLastSecondaryStreetSurveyNumber(STREET_ID);

            if (lastSecondaryStSurveyNum == 0)
            {
                // no surveys have been done over this secondar street, so we can update its length and width directly
                //sql = string.Format("UPDATE SECONDARY_STREETS SET SECOND_ST_WIDTH={0}, SECOND_ST_LENGTH={1}, ARNAME={2}, SECOND_ARNAME={2} WHERE SECOND_ID={3} ",
                sql = string.Format("UPDATE STREETS SET SECOND_ST_WIDTH={0}, SECOND_ST_LENGTH={1}, ARNAME={2}, SECOND_ARNAME={2} WHERE STREET_ID={3} ",
                                    SECOND_ST_WIDTH, SECOND_ST_LENGTH, SECOND_AR_NAME, STREET_ID);

                int rows = db.ExecuteNonQuery(sql);


                sql = string.Format("UPDATE SECONDARY_STREET_DETAILS SET SECOND_ST_WIDTH={0}, SECOND_ST_LENGTH={1}, ARNAME={2}, SECOND_AR_NAME={2} WHERE STREET_ID={3} ",
                                    SECOND_ST_WIDTH, SECOND_ST_LENGTH, SECOND_AR_NAME, STREET_ID);

                rows += db.ExecuteNonQuery(sql);

                Shared.SaveLogfile("SECONDARY_STREETS", STREET_ID.ToString(), "Update", user);
                return(rows > 0);
            }
            else
            {
                // surveys have been done over this secondar street, so we have to remove them before we can update its length and width directly
                sql = string.Format("UPDATE STREETS SET SECOND_ST_WIDTH={0}, SECOND_ST_LENGTH={1}, ARNAME={2}, SECOND_ARNAME={2}, NOTES={4} WHERE STREET_ID={3} ",
                                    SECOND_ST_WIDTH, SECOND_ST_LENGTH, SECOND_AR_NAME, STREET_ID, NOTES);

                int rows = db.ExecuteNonQuery(sql);

                sql = string.Format("UPDATE SECONDARY_STREET_DETAILS SET SECOND_ST_WIDTH={0}, SECOND_ST_LENGTH={1}, ARNAME={2}, SECOND_AR_NAME={2} WHERE STREET_ID={3} ",
                                    SECOND_ST_WIDTH, SECOND_ST_LENGTH, SECOND_AR_NAME, STREET_ID);

                rows += db.ExecuteNonQuery(sql);
                rows += new SecondaryStreets().FixDistressesAfterAreaChange(SECOND_ST_LENGTH, SECOND_ST_WIDTH, STREET_ID, user);

                sql = string.Format("DELETE FROM MAINTENANCE_DECISIONS WHERE STREET_ID={0} ", STREET_ID); // second_id
                db.ExecuteNonQuery(sql);


                Shared.SaveLogfile("SECONDARY_STREETS", STREET_ID.ToString(), "Update with nulling UDI", user);
                return(rows > 0);
            }
        }