public Int32 SubmitTimesheetEntry(string UsrNam, string UsrPwd, DateTime DateVal, Int32 ProjectId, Int32 TaskId, Int32 StatusId, string Comment, string JobRef, double Hours) { Int32 RetVal = 0; try { Int32 UserId = GetUserId(UsrNam, UsrPwd); if (UserId > 0) { ClassTime oTim = new ClassTime(); oTim.DateVal = DateVal; oTim.UserId = UserId; oTim.ProjectId = ProjectId; oTim.TaskId = TaskId; oTim.StatusId = StatusId; oTim.Comment = Comment; oTim.JobRef = JobRef; oTim.Hours = Hours; RetVal = oTim.Save(0); } else { // Valid user not found! RetVal = -1; } } catch (Exception ex) { Log.LogMsg(ex.Message); RetVal = -1; } return RetVal; }
protected void BtnSubmit_Click(object sender, EventArgs e) { //ClassTask oTsk = new ClassTask(Convert.ToInt32(this.DdlTasks.SelectedValue)); //Boolean bOkay = false; Boolean bOkay = true; //if ((oTsk.ValidationType & (Int32)Enum.ValidationType.NoValidation) != 0) //{ // // No validation for job reference. User can enter anything // // they like. // bOkay = true; //} //else if ((oTsk.ValidationType & (Int32)Enum.ValidationType.JobMustPreExist) != 0) //{ // // Job must pre-exist and be active in tblJobs. // //ClassJob oJob = new ClassJob(); // //if (oJob.IsJobActive(this.TxtReference.Text) == true) // //{ // // // Job reference is available and is active. // // bOkay = true; // //} // //else // //{ // // // Job reference either doesn't exist or it isn't // // // currently active in tblJobs. // // bOkay = false; // // ShowTimeError("Job reference does not pre-exist!"); // //} //} //else if ((oTsk.ValidationType & (Int32)Enum.ValidationType.UseRegularExpression) != 0) //{ // // Job reference must meet regular expression. // //System.Text.RegularExpressions.Regex oReg = new System.Text.RegularExpressions.Regex(oTsk.ReferenceRegEx); // //if (oReg.IsMatch(this.TxtReference.Text) == true) // //{ // // // Regular expression match is okay. // // bOkay = true; // //} // //else // //{ // // // Regular expression failed. // // bOkay = false; // // ShowTimeError("Job reference failed regular expression check!"); // //} //} //else if ((oTsk.ValidationType & (Int32)Enum.ValidationType.UseDropDownListBox) != 0) //{ // // Job reference supplied via dropdown listbox. // if (this.DdlJobs.Items.Count > 0) // { // // The user has selected via the dropdown listbox. // //this.TxtReference.Text = this.DdlJobs.SelectedValue; // bOkay = true; // } //} if (bOkay == true) { // We have passed the job reference validation check (if any). ClassTime oTim = new ClassTime(Convert.ToInt32(ViewState["TimeId"].ToString())); ClassUser oUsr = new ClassUser(); oTim.DateVal = this.cc2DateSelector.GetDate(); oTim.UserId = Int32.Parse(ViewState["UserId"].ToString()); oTim.ProjectId = Convert.ToInt32(this.ddlProjects.SelectedValue); //oTim.TaskId = oTsk.TaskId; //oTim.StatusId = Convert.ToInt32(this.ddlStatus.SelectedValue); //oTim.Comment = this.TxtComment.Text; //oTim.JobRef = this.TxtReference.Text; // Check that hours entered is a valid number. System.Text.RegularExpressions.Regex oReg = new System.Text.RegularExpressions.Regex("[-+]?[0-9]*\\.?[0-9]+"); if (!oReg.IsMatch(this.txtTotalHours.Text)) { // Regular expression for hours failed. ShowTimeError("The hours entered are incorrectly specified!"); } else { // Hours entered is a valid number. double HoursVal; if (double.TryParse(this.txtTotalHours.Text, out HoursVal) != true) { // Problem with the submitted hours value. ShowTimeError("The hours entered are invalid!"); } else { // Hours value is okay. oTim.Hours = HoursVal; oTim.Save(Int32.Parse(ViewState["TimeId"].ToString())); ShowTime(oTim.TimeId); ShowGrid(0); ViewState["TimeId"] = "0"; //this.TxtComment.Text = ""; this.txtTotalHours.Text = "0.00"; this.LblTimeId.Text = "New"; this.BtnSubmit.Text = "Submit"; ResetTime(); EnableControls(false); BtnSubmit.Enabled = false; } } } //this.DdlProject.Focus(); }