private void AddNewStatusHistory()
        {
            StatusHistory objStatus = new StatusHistory();
            objStatus.AddNew();

            objStatus.PricingStatusID = int.Parse(ui_drpTradeStatus.SelectedValue);
            objStatus.StatusDate = DateTime.Now;
            objStatus.Comment = ui_txtStatusComment.Text;
            objStatus.TradePricingID = TradePriceID;
            objStatus.AttachementPath = "";
            objStatus.Save();

            // if file exist - save it with the current record
            if (ui_fileStatusUpload.HasFile)
            {
                objStatus.AttachementPath = SaveStatusFile(objStatus.StatusHistoryID);
                objStatus.Save();
            }

            // Upate the Trade Pricing Record with the last status we have .
            TradePricing objTradePricing = new TradePricing();
            objTradePricing.LoadByPrimaryKey(TradePriceID);
            objTradePricing.PricingStatusID = objStatus.PricingStatusID;
            objTradePricing.DiscussionDate = DateTime.Now.ToString(); // Record status change date.
            objTradePricing.Save();
        }
        /// <summary>
        /// Saving new pricing request
        /// </summary>
        private void SavePricingRequest()
        {
            try
            {
                TradePricing objPricing = new TradePricing();

                objPricing.AddNew();

                objPricing.CompanyID = Int32.Parse(ui_drpCompanies.SelectedValue);
                objPricing.ManufactureID = Int32.Parse(ui_drpManufactures.SelectedValue);
                objPricing.TradeName = ui_txtTradeName.Text;
                objPricing.SubmissionDate = ui_txtSubmissionDate.Text;
                objPricing.CompanyPrice = float.Parse(ui_txtPrice.Text);
                objPricing.DosageFormID = Int32.Parse(ui_drpDosageForm.SelectedValue);
                objPricing.RegistrationCommitteTypeID = Int32.Parse(ui_drpCommitteType.SelectedValue);
                objPricing.Pack = ui_txtPack.Text;
                objPricing.FileNo = ui_txtFileNo.Text;
                objPricing.FileTypeID = Int32.Parse(ui_drpFileType.SelectedValue);
                objPricing.PricingStatusID = 1;
                objPricing.DiscussionDate = DateTime.Now.ToString(); // Update the status changes date .
                objPricing.ImportedManufacture = ui_txtImportedManufacture.Text;
                //TODO: Save File to disk and save it's path.
                objPricing.FilePath = "";

                objPricing.Save();

                // Save File.
                string savedFileName = SaveFile(objPricing.TradePricingID);
                objPricing.FilePath = savedFileName;
                objPricing.Save();

                ShowUploadedFile(savedFileName, objPricing.TradePricingID);

                ui_lblResult.ForeColor = System.Drawing.Color.Green;
                ui_lblResult.Text = "The new record saved successfully";

                // Insert Inistial Status record for the new rquest ( status = initiated )
                //-----------------------------------------------------------------------
                StatusHistory objStatus = new StatusHistory();
                objStatus.AddNew();
                objStatus.PricingStatusID = 1; // Will be initiated by default.
                objStatus.StatusDate = DateTime.Now;
                objStatus.TradePricingID = objPricing.TradePricingID;
                objStatus.CurrentPrice = objPricing.CompanyPrice;
                objStatus.Save();
                //--------------------------------------------------------------

                //Response.Redirect("New_Request.aspx?ID=" + objPricing.TradePricingID + "&type=new#tab_1_2");

                TradePriceID = objPricing.TradePricingID;
                InitializeUpdateMode();

            }
            catch
            {
                ui_lblResult.ForeColor = System.Drawing.Color.Red;
                ui_lblResult.Text = "Problem while saving the new record";
            }
        }
        private void AddNewStatusHistory()
        {
            // condition added to solve refresh postback action
            if (Session["RefreshHit_Capa_ts"].ToString() == ViewState["RefreshHit_Capa_ts"].ToString())
            {
                StatusHistory objStatus = new StatusHistory();
                objStatus.AddNew();

                objStatus.PricingStatusID = int.Parse(ui_drpTradeStatus.SelectedValue);
                objStatus.StatusDate = DateTime.Now;
                objStatus.Comment = ui_txtStatusComment.Text;
                objStatus.TradePricingID = TradePriceID;
                objStatus.AttachementPath = "";

                if (ui_drpTradeStatus.SelectedValue == "5")
                {
                    objStatus.CommitteeTypeID = int.Parse(ui_drpCommitteeTypes.SelectedValue);
                    DateTime comDate = DateTime.Parse(ui_txtCommitteeDate.Text + " " + drpCommitteeHours.SelectedItem.Text + ":" + drpCommitteeMinutes.SelectedItem.Text + ":00");
                    objStatus.CommitteDate = comDate;
                }
                objStatus.Save();

                // if file exist - save it with the current record
                if (ui_fileStatusUpload.HasFile)
                {
                    objStatus.AttachementPath = SaveStatusFile(objStatus.StatusHistoryID);
                    objStatus.Save();
                }

                // Upate the Trade Pricing Record with the last status we have .
                TradePricing objTradePricing = new TradePricing();
                objTradePricing.LoadByPrimaryKey(TradePriceID);
                objTradePricing.PricingStatusID = objStatus.PricingStatusID;
                objTradePricing.DiscussionDate = DateTime.Now.ToString();
                objTradePricing.Save();

                //solve refresh postback action
                Session["RefreshHit_Capa_ts"] = Server.UrlEncode(System.DateTime.Now.ToString());
            }
        }