/// <summary> /// This method defines the behavior of the Submit button for the create /// intervention page. Once the values are inserted in the form and the user /// selects the submit button all the data is collected and a new intervention /// is created. If the labor and cost fields are empty then the default cost and /// value for the intervention is collected from the database using the Data Operator /// from the Data Layer folder. Once all the fields are validated, a new core info record /// is created, the user is then redirected to the client detail page with the listing /// of all interventions related to that client and the newly created intervention. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { // Todo: Style of date input; // Todo: Style of button; int getLabour = 0; int getCost = 0; int getIntType = int.Parse(ddInt.SelectedValue); int getCID = int.Parse(hfClientID.Value); if (txtLabour.Text == "" || txtCost.Text == "") { DataLayer.DataOperator intType = new DataLayer.DataOperator(); IMS.DataLayer.interventionType intTypeRow = intType.GetIntTypeByID(getIntType); getLabour = int.Parse(intTypeRow.amount_of_labour); getCost = int.Parse(intTypeRow.cost_of_materials); } else { getLabour = int.Parse(txtLabour.Text); getCost = int.Parse(txtCost.Text); } DataLayer.DataOperator dataUserInfo = new DataLayer.DataOperator(); string UID = User.Identity.GetUserId().ToString(); IMS.DataLayer.view_user user = dataUserInfo.GetUserByID(UID); int UserID = user.users_ID; DataLayer.DataOperator obj = new DataLayer.DataOperator(); obj.CreateCoreInfo(getIntType, getCID, getLabour, getCost, UserID, DateTime.Parse(txtDate.Text), "Proposed", "", 0, DateTime.Now); Response.Redirect("eng_detail_client?cid=" + getCID); }
/// <summary> /// Before the list of interventions page is loaded the district id /// of the user is obtained and the sql data source's select command is /// created to include the district ID for the current user, in order to /// display all the interventions that relate to that district. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { String UID = User.Identity.GetUserId().ToString(); DataLayer.DataOperator obj = new DataLayer.DataOperator(); IMS.DataLayer.view_user user = obj.GetUserByID(UID); int DID = user.Districts_ID; SqlDataSource1.SelectCommand = "SELECT [interventionTypes_name], [clients_name], [status], [iDate], [coreInfo_ID] FROM [view_detail_interventions] WHERE ([Districts_ID] = " + DID + ")"; }
/// <summary> /// For this page, before the page is loaded the User ID is obtained to gather the /// user ID from which the district ID is gathered in order to show a list of clients /// that belong to that specific district. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { //int UID = int.Parse(User.Identity.GetUserId()); String UID = User.Identity.GetUserId().ToString(); DataLayer.DataOperator obj = new DataLayer.DataOperator(); IMS.DataLayer.view_user user = obj.GetUserByID(UID); int DID = user.Districts_ID; SqlDataSource1.SelectCommand = "SELECT [name], [descriptive], [Districts], [clients_ID] FROM [view_client_list] WHERE ([district_id] = " + DID + ")"; }
/// <summary> /// Before this page is created the user id from the URL is used to find the user details /// in order to determine the district id for the District drop down list which is set permanently /// based on the User's District location. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string UID = User.Identity.GetUserId().ToString(); DataLayer.DataOperator obj = new DataLayer.DataOperator(); IMS.DataLayer.view_user user = obj.GetUserByID(UID); int DID = user.Districts_ID; DataLayer.DataOperator dbo = new DataLayer.DataOperator(); ddDistrict.DataSource = dbo.GetDistrictList(); ddDistrict.DataBind(); ddDistrict.SelectedValue = DID.ToString(); } }