Example #1
0
        /// <summary>
        /// Handles the Click event of the buttonSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void buttonSave_Click(object sender, EventArgs e)
        {
            string strvalue = this.Request[hdServiceTestId.UniqueID].ToString();
            string v1       = hdServiceTestId.Value;

            try
            {
                int serviceOrderId = Int32.Parse(strvalue);

                int             resultBy   = Convert.ToInt32(ddlReportedbyName.SelectedValue);
                string          strResult  = textResult.Text;
                string          strDate    = txtReportedbyDate.Text;
                IServiceRequest requestMgr = (IServiceRequest)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BServiceRequest, BusinessProcess.Clinical");
                OrderedService  service    = this.thisOrder.Services.DefaultIfEmpty(null).FirstOrDefault(s => s.Id == serviceOrderId);

                if (resultBy > 0 && strResult != "" && strDate != "" && null != service)
                {
                    DateTime resultDate = Convert.ToDateTime(strDate);
                    if (thisOrder.OrderDate > resultDate)
                    {
                        this.NotifyAction("Wrong information: result date cannot be before the order date", "Validation", true, "");
                        this.ServiceDialog.Show();
                        return;
                    }
                    service.ResultNotes = strResult;
                    service.ResultDate  = resultDate;
                    service.ResultBy    = resultBy;
                    List <OrderedService> services = new List <OrderedService>();
                    services.Add(service);
                    requestMgr.SaveOrderResult(services, this.ServiceOrderId, this.UserId);
                    this.PopulateRequest();
                    BindServices();
                    this.NotifyAction("Results has been saved", "Success", false, "javascript:HideModalPopup();return true;");
                    return;
                }
                else
                {
                    this.NotifyAction("Missing information, specify all the field", "Validation", true, "");
                    this.ServiceDialog.Show();
                    return;
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ref ex);
            }
        }