Beispiel #1
0
    protected void btnnew_Click(object sender, EventArgs e)
    {
        Whitfieldcore _wc = new Whitfieldcore();

        _wc.AddBidAmount(Convert.ToInt32(ViewState["EstNum"].ToString()), Convert.ToInt32(ViewState["Compeid"].ToString()), txtBidAmt.Text);
        lblMsg.Text = "Your record is added successfully.";
    }
 protected void btnnew_Click(object sender, EventArgs e)
 {
     Whitfieldcore wUser = new Whitfieldcore();
         wUser.ManageWorkOrders(Convert.ToInt32(ViewState["EstNum"].ToString()), txtdesc.Text.Trim(), Convert.ToInt32(txtMaterialCost.Text.Trim()), Convert.ToInt32(txtFabHours.Text.Trim()), Convert.ToInt32(txtFinishHours.Text.Trim()), Convert.ToInt32(txtInstallHours.Text.Trim()), Convert.ToInt32(txtEngHours.Text.Trim()), Convert.ToInt32(txtMiscHours.Text.Trim()), txtNotes.Text.Trim(), chkActive.SelectedItem.Value.Trim(), txtreftext.Text.Trim());
         //Response.Write("<script language='javascript'>parent.agreewin.hide();</script>");
         Response.Write("<script language='javascript'>parent.location.replace('whitfield_estimation.aspx?EstNum=" + hidEstNum.Value + "');</script>");
 }
    public void FetchAndBind(Int32 _ArchID)
    {
        //[Architect] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
        //[Address] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
        //[City] [int] NULL,
        //[State] [int] NULL,
        //[Zip] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
        //[Phone] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
        //[Fax] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
        //[Web] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
        //[Notes] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

        Whitfieldcore _wc = new Whitfieldcore();
        IDataReader iReader = _wc.GetArchitectInfo(_ArchID);
        // ' Loop through the DataReader and write out each entry
        while (iReader.Read())
        {
            txtclientname.Text = iReader["Architect"] == DBNull.Value ? "" : iReader["Architect"].ToString();
            txtstreet.Text = iReader["Address"] == DBNull.Value ? "" : iReader["Address"].ToString();
            String City = iReader["City"] == DBNull.Value ? "" : iReader["City"].ToString();
            ddlCity.SelectedIndex = ddlCity.Items.IndexOf(ddlCity.Items.FindByValue(City.ToString()));
            String Statecd = iReader["State"] == DBNull.Value ? "" : iReader["State"].ToString();
            ddlState.SelectedIndex = ddlState.Items.IndexOf(ddlState.Items.FindByValue(Statecd.ToString()));
            txtZipcode.Text = iReader["Zip"] == DBNull.Value ? "" : iReader["Zip"].ToString();
            txtPhNumber.Text = iReader["Phone"] == DBNull.Value ? "" : iReader["Phone"].ToString();
            txtFaxNumber.Text = iReader["Fax"] == DBNull.Value ? "" : iReader["Fax"].ToString();
            txtWeb.Text = iReader["Web"] == DBNull.Value ? "" : iReader["Web"].ToString();
            txtNotes.Text = iReader["Notes"] == DBNull.Value ? "" : iReader["Notes"].ToString();
        }
    }
    public void DisplayListBoxValues()
    {
        try
        {
            try
            {
                Whitfieldcore wCore = new Whitfieldcore();
                DataSet dsRight = new DataSet();
                DataSet dsLeft = new DataSet();

                dsLeft = wCore.GetLeftDistributionList(Convert.ToInt32(ViewState["EstNum"].ToString()), Convert.ToInt32(ViewState["twcProjNumber"].ToString()));
                BindUsers(leftlist, dsLeft);
                dsRight = wCore.GetRightDistributionList(Convert.ToInt32(ViewState["twcProjNumber"].ToString()));
                BindUsers(rightlist, dsRight);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
    protected void btnnew_Click(object sender, EventArgs e)
    {
        Whitfieldcore wc = new Whitfieldcore();
        if (Page.IsValid)
        {
            Boolean IsInsertSuccess = false;
            IsInsertSuccess = wc.ManageContacts(Convert.ToInt32(ViewState["ContactID"].ToString()),
                Convert.ToInt32(ViewState["ClientNum"].ToString()),
                txtcontactfname.Text.Trim(),
                txtcontactlname.Text.Trim(),
                ddltitle.SelectedItem.Value,
                txttele.Text.Trim(),
                txtextn.Text.Trim(),
                txtEmail.Text.Trim(),
                txtNotes.Text.Trim(),
                txtAddress.Text.Trim(),
                ddlCity.SelectedItem.Value,
                ddlState.SelectedItem.Value,
                txtzip.Text.Trim()
                );
            if (IsInsertSuccess)
            {
                //Response.Redirect("addclient.aspx?IsNew=N&hClientID=" + ViewState["ClientNum"].ToString());

                //Response.Write("<script language='javascript'>parent.agreewin.hide();</script>");

                lblMsg.Text = "Client is Successfully saved";
            }
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     Whitfieldcore _wc = new Whitfieldcore();
     if (!Page.IsPostBack)
     {
         // 1 Get collection
         NameValueCollection n = Request.QueryString;
         // 2 See if any query string exists
         if (n.HasKeys())
         {
             // 3 Get first key and value
             string k = n.GetKey(0);
             string v = n.Get(0);
             string v1 = n.Get(1);
             // 4
             // Test different keys
             Clientid = Convert.ToInt32(v);
             EstNum = Convert.ToInt32(v1);
             hidEstNum.Value = EstNum.ToString();
         }
         ViewState["EstNum"] = EstNum.ToString();
         ViewState["Clientid"] = Clientid.ToString();
         BindContacts(Clientid);
     }
 }
Beispiel #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Whitfieldcore _wc = new Whitfieldcore();

        if (!Page.IsPostBack)
        {
            // 1 Get collection
            NameValueCollection n = Request.QueryString;
            // 2 See if any query string exists
            if (n.HasKeys())
            {
                // 3 Get first key and value
                string k  = n.GetKey(0);
                string v  = n.Get(0);
                string v1 = n.Get(1);
                // 4
                // Test different keys
                Compeid            = Convert.ToInt32(v);
                EstNum             = Convert.ToInt32(v1);
                hidEstNum.Value    = EstNum.ToString();
                txtBidAmt.Text     = _wc.GetBidAmt(EstNum, Compeid);
                txtClientName.Text = _wc.GetClientName(EstNum);
                txtEstName.Text    = _wc.GetProjectName(EstNum);
            }
            ViewState["EstNum"]  = EstNum.ToString();
            ViewState["Compeid"] = Compeid.ToString();
        }
    }
 public void PageResultGrid1(object sender, DataGridPageChangedEventArgs e)
 {
     DataSet dsGridResults;
     grdRpResults.CurrentPageIndex = e.NewPageIndex;
     Whitfieldcore wUser = new Whitfieldcore();
     dsGridResults = wUser.GetAllSubMaterials(ddlMatType.SelectedItem.Value, "Grid");
     this.PopulateDataGrid(dsGridResults);
 }
 public void PageResultGridNotes(object sender, DataGridPageChangedEventArgs e)
 {
     Whitfieldcore wc = new Whitfieldcore();
     DataSet dsGridResults;
     grdSchedule.CurrentPageIndex = e.NewPageIndex;
     dsGridResults = wc.GetCummululativeProjectSchedule();
     this.PopulateDataGrid(dsGridResults, grdSchedule,ddlYear.SelectedItem.Value, ddlMonth.SelectedItem.Value + "(" + ddlYear.SelectedItem.Value + ")");
 }
 public void PageResultGridNotes(object sender, DataGridPageChangedEventArgs e)
 {
     Whitfieldcore wc = new Whitfieldcore();
     DataSet dsGridResults;
     grdSchedule.CurrentPageIndex = e.NewPageIndex;
     dsGridResults = wc.GetCummululativeProjectSchedule();
     this.PopulateDataGrid(dsGridResults, grdSchedule);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     Whitfieldcore _wc = new Whitfieldcore();
     if (!Page.IsPostBack)
     {
         BindMaterials();
     }
 }
 public void grdpl1_DeleteCommand(object sender, DataGridCommandEventArgs e)
 {
     String DetailId = "";
     DetailId = grdpl1.DataKeys[Convert.ToInt32(e.Item.ItemIndex)].ToString();
     Whitfieldcore _dbClass = new Whitfieldcore();
     _dbClass.DeleteSubMaterials(Convert.ToInt32(DetailId));
     this.DisplayGrid(Convert.ToInt32(ViewState["material_id"].ToString()));
 }
 public void grdpl1_UpdateCommand(object sender, DataGridCommandEventArgs e)
 {
     String DetailId = grdpl1.DataKeys[Convert.ToInt32(e.Item.ItemIndex)].ToString();
     Whitfieldcore _dbClass = new Whitfieldcore();
     _dbClass.UPDATESubMaterials(Convert.ToInt32(DetailId), ((TextBox)(e.Item.FindControl("txtthickness"))).Text, ((TextBox)(e.Item.FindControl("txtlength"))).Text, ((TextBox)(e.Item.FindControl("txtweight"))).Text, ((TextBox)(e.Item.FindControl("txtwidth"))).Text, ((TextBox)(e.Item.FindControl("txtDescription"))).Text, ((TextBox)(e.Item.FindControl("txtCost"))).Text, Convert.ToInt32(((DropDownList)(e.Item.FindControl("ddlUOM"))).SelectedItem.Value), ((RadioButtonList)(e.Item.FindControl("chkLEED"))).SelectedItem.Value, ((TextBox)(e.Item.FindControl("txtManufacturer"))).Text, ((RadioButtonList)(e.Item.FindControl("chkFSC"))).SelectedItem.Value, ((TextBox)(e.Item.FindControl("txtMaterial_Code"))).Text, ((TextBox)(e.Item.FindControl("txtNotes"))).Text, ((RadioButtonList)(e.Item.FindControl("chkDefault_Field"))).SelectedItem.Value);
     grdpl1.EditItemIndex = -1;
     grdpl1.ShowFooter = true;
     this.DisplayGrid(Convert.ToInt32(ViewState["material_id"].ToString()));
 }
 protected void btnnew_Click(object sender, EventArgs e)
 {
     Whitfieldcore wUser = new Whitfieldcore();
     //ArrayList chkArray = GetSelectedItems(ChkProjContacts
     for (int i = 0; i < RdoPrjClient.Items.Count; i++)
     {
         if (RdoPrjClient.Items[i].Selected)
             wUser.AddPrimaryContact(Convert.ToInt32(ViewState["EstNum"].ToString()), Convert.ToInt32(ViewState["Clientid"].ToString()), Convert.ToInt32(RdoPrjClient.Items[i].Value));
     }
 }
 public void grdpl1_UpdateCommand(object sender, DataGridCommandEventArgs e)
 {
     String DetailId = grdpl1.DataKeys[Convert.ToInt32(e.Item.ItemIndex)].ToString();
     Whitfieldcore _dbClass = new Whitfieldcore();
     _dbClass.UPDATEMaterialinWorkOrder(Convert.ToInt32(ViewState["EstNum"].ToString()), ViewState["WorkOrderID"].ToString(), Convert.ToInt32(DetailId), ((TextBox)(e.Item.FindControl("txtqty"))).Text);
     grdpl1.EditItemIndex = -1;
     grdpl1.ShowFooter = true;
     this.DisplayGrid(Convert.ToInt32(ViewState["EstNum"].ToString()), ViewState["WorkOrderID"].ToString());
     Page.GetType().InvokeMember("DisplayGrid", BindingFlags.InvokeMethod, null, this.Page, null);
 }
 public void grd1_DeleteCommand(object sender, DataGridCommandEventArgs e)
 {
     contingency _wc = new contingency();
     String DetailId = "";
     DetailId = grd1.DataKeys[Convert.ToInt32(e.Item.ItemIndex)].ToString();
     Whitfieldcore _dbClass = new Whitfieldcore();
     _wc.DeleteSubContingency(Convert.ToInt32(DetailId));
     DataSet dsGridResults = _wc.FetchSubContingencyData(Convert.ToInt32(ViewState["cont_id"].ToString()));
     PopulateDataGrid(dsGridResults, grd1);
 }
 public void grdpl1_DeleteCommand(object sender, DataGridCommandEventArgs e)
 {
     String DetailId = "";
     DetailId = grdpl1.DataKeys[Convert.ToInt32(e.Item.ItemIndex)].ToString();
     Whitfieldcore _dbClass = new Whitfieldcore();
     _dbClass.DELETEMaterialinWorkOrder(Convert.ToInt32(ViewState["EstNum"].ToString()), ViewState["WorkOrderID"].ToString(),Convert.ToInt32(DetailId));
     this.DisplayGrid(Convert.ToInt32(ViewState["EstNum"].ToString()), ViewState["WorkOrderID"].ToString());
        // ((YourPageClass)this.Page).YourMethod();
     Page.GetType().InvokeMember("DisplayGrid", BindingFlags.InvokeMethod, null, this.Page, null);
 }
 public void BindMonths()
 {
     DataSet dsGrp = new DataSet();
     Whitfieldcore wUser = new Whitfieldcore();
     DataSet hash = wUser.GetMonths();
     ddlMonth.DataSource = hash;
     ddlMonth.DataTextField = "month_name";
     ddlMonth.DataValueField = "month_name";
     ddlMonth.DataBind();
 }
 public void grdEstimateMaterials_DeleteCommand(object sender, DataGridCommandEventArgs e)
 {
     contingency _wc = new contingency();
     String DetailId = "";
     DetailId = grdEstimateMaterials.DataKeys[Convert.ToInt32(e.Item.ItemIndex)].ToString();
     Whitfieldcore _dbClass = new Whitfieldcore();
     _wc.DeleteTerms(Convert.ToInt32(DetailId));
     _wc.DeleteSubTermsForTems(Convert.ToInt32(DetailId));
     DataSet dsGridResults = _wc.FetchTermsData();
     PopulateDataGrid(dsGridResults, grdEstimateMaterials);
 }
 protected void btnnew_Click(object sender, EventArgs e)
 {
     Whitfieldcore wUser = new Whitfieldcore();
     wUser.DeleteProjectClient(Convert.ToInt32(ViewState["EstNum"].ToString()));
     //ArrayList chkArray = GetSelectedItems(ChkProjContacts
     for (int i = 0; i < ChkPrjClient.Items.Count; i++)
     {
         if (ChkPrjClient.Items[i].Selected)
             wUser.PopulateProject_client(Convert.ToInt32(ViewState["EstNum"].ToString()), Convert.ToInt32(ChkPrjClient.Items[i].Value));
     }
     lblMsg.Text = "Your record is added successfully.";
 }
 protected void btnnew_Click(object sender, EventArgs e)
 {
     Whitfieldcore wUser = new Whitfieldcore();
     //ArrayList chkArray = GetSelectedItems(ChkProjContacts
     for (int i = 0; i < RdoprjMaterials.Items.Count; i++)
     {
         if (RdoprjMaterials.Items[i].Selected)
             wUser.PopulateMaterialinWorkOrder(Convert.ToInt32(ViewState["EstNum"].ToString()), ViewState["WorkOrderNumber"].ToString(), Convert.ToInt32(RdoprjMaterials.Items[i].Value));
     }
     //Response.Write("<script language='javascript'>parent.location.replace('whitfield_estimation.aspx');</script>");
     Response.Write("<script language='javascript'>parent.location.replace('Whitfield_estimation.aspx?EstNum=" + ViewState["EstNum"].ToString() + "');</script>");
 }
 private void BindContingency(Int32 EstNum)
 {
     DataSet dsGrp = new DataSet();
     Whitfieldcore wUser = new Whitfieldcore();
     dsGrp = wUser.GetMasterContingencies(EstNum);
     if (dsGrp.Tables[0].Rows.Count > 0)
     {
         ChkCongingency.DataSource = dsGrp;
         ChkCongingency.DataTextField = "description";
         ChkCongingency.DataValueField = "sub_contingency_id";
         ChkCongingency.DataBind();
     }
 }
 private void BindSubMaterials()
 {
     DataSet dsGrp = new DataSet();
     Whitfieldcore wUser = new Whitfieldcore();
     dsGrp = wUser.GetMaterialForEsitmation(Convert.ToInt32(ViewState["EstNum"].ToString()));
     if (dsGrp.Tables[0].Rows.Count > 0)
     {
       RdoprjMaterials.DataSource = dsGrp;
       RdoprjMaterials.DataTextField = "OrigMatName";
       RdoprjMaterials.DataValueField = "sub_mat_id";
       RdoprjMaterials.DataBind();
     }
 }
    protected void btnnew_Click(object sender, EventArgs e)
    {
        Whitfieldcore wUser = new Whitfieldcore();

        //ArrayList chkArray = GetSelectedItems(ChkProjContacts
        for (int i = 0; i < RdoPrjClient.Items.Count; i++)
        {
            if (RdoPrjClient.Items[i].Selected)
            {
                wUser.AddPrimaryContact(Convert.ToInt32(ViewState["EstNum"].ToString()), Convert.ToInt32(ViewState["Clientid"].ToString()), Convert.ToInt32(RdoPrjClient.Items[i].Value));
            }
        }
    }
 private void BindContacts(Int32 Clientid)
 {
     DataSet dsGrp = new DataSet();
     Whitfieldcore wUser = new Whitfieldcore();
     dsGrp = wUser.GetContactsForClients(Clientid);
     if (dsGrp.Tables[0].Rows.Count > 0)
     {
         RdoPrjClient.DataSource = dsGrp;
         RdoPrjClient.DataTextField = "FName";
         RdoPrjClient.DataValueField = "ContactID";
         RdoPrjClient.DataBind();
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        Whitfieldcore wc = new Whitfieldcore();
        if (!Page.IsPostBack)
        {
            DataSet ds = new DataSet();
            ds = wc.GetSchedule("01/01/2010", "08/01/2010");
            Int32 resultCount = 0;

            if (ds.Tables.Count > 0)
                resultCount = ds.Tables[0].Rows.Count;

            DataTable myControls;
            myControls = ds.Tables[0];
            Int32 iCnt = 1;
            if (myControls.Rows.Count > 0)
            {
                try
                {
                    foreach (DataRow dRow in myControls.Rows)
                    {
                        Hashtable hash = wc.GetWeeksHash();
                        String _yr = dRow["dt2"] != DBNull.Value ? dRow["dt2"].ToString() : "";
                        String _mnth = dRow["dt1"] != DBNull.Value ? dRow["dt1"].ToString() : "";
                        foreach (string key in hash.Keys)
                        {
                            //+ '(' + [fycd] + ')'
                            wc.PopulateSchedule(1, _yr, _mnth + "(" + _yr + ")", hash[key].ToString(),iCnt,"0");
                            //passs
                            //_yr
                            //_mnth
                            //hash[key].ToString()
                            //ProjectNumber to the Maintainschedule
                        }
                        iCnt++;
                    }
                    Response.Write("setup Completed.");
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            }
            else
            {
                Response.Write("No Data");

            }

        }
    }
    private void BindAwardedProjects()
    {
        DataSet dsGrp = new DataSet();
        Whitfieldcore wProjects = new Whitfieldcore();
        dsGrp = wProjects.GetProjectInfo("", "", "5");
        if (dsGrp.Tables[0].Rows.Count > 0)
        {

            RdoAwdProjects.DataSource = dsGrp;
            RdoAwdProjects.DataTextField = "ProjName";
            RdoAwdProjects.DataValueField = "EstNum";
            RdoAwdProjects.DataBind();
        }
    }
    private void BindClient()
    {
        DataSet dsGrp = new DataSet();
        Whitfieldcore wUser = new Whitfieldcore();
        dsGrp = wUser.GetClientlist();
        if (dsGrp.Tables[0].Rows.Count > 0)
        {

          ChkPrjClient.DataSource = dsGrp;
          ChkPrjClient.DataTextField = "Name";
          ChkPrjClient.DataValueField = "ClientID";
          ChkPrjClient.DataBind();
        }
    }
    private void BindQuals(Int32 EstNum)
    {
        DataSet dsGrp = new DataSet();
        Whitfieldcore wUser = new Whitfieldcore();
        dsGrp = wUser.GetMasterQualification(EstNum);
        if (dsGrp.Tables[0].Rows.Count > 0)
        {

            Chkqualification.DataSource = dsGrp;
            Chkqualification.DataTextField = "description";
            Chkqualification.DataValueField = "sub_qual_id";
            Chkqualification.DataBind();
        }
    }
    private void BindContacts(Int32 Clientid)
    {
        DataSet       dsGrp = new DataSet();
        Whitfieldcore wUser = new Whitfieldcore();

        dsGrp = wUser.GetContactsForClients(Clientid);
        if (dsGrp.Tables[0].Rows.Count > 0)
        {
            RdoPrjClient.DataSource     = dsGrp;
            RdoPrjClient.DataTextField  = "FName";
            RdoPrjClient.DataValueField = "ContactID";
            RdoPrjClient.DataBind();
        }
    }
    private void BindCompetition()
    {
        DataSet dsGrp = new DataSet();
        Whitfieldcore wUser = new Whitfieldcore();
        dsGrp = wUser.GetCompetitors();
        if (dsGrp.Tables[0].Rows.Count > 0)
        {

            ChkProjContacts.DataSource = dsGrp;
            ChkProjContacts.DataTextField = "Name";
            ChkProjContacts.DataValueField = "CompeID";
            ChkProjContacts.DataBind();
        }
    }
 public void FetchFromClient(Int32 _clientNum)
 {
     Whitfieldcore _wc = new Whitfieldcore();
     IDataReader iReader = _wc.GetClientInfo(_clientNum);
     while (iReader.Read())
     {
         txttele.Text = iReader["Phone"] == DBNull.Value ? "" : iReader["Phone"].ToString();
         txtFax.Text = iReader["Fax"] == DBNull.Value ? "" : iReader["Fax"].ToString();
         txtAddress.Text = iReader["Street"] == DBNull.Value ? "" : iReader["Street"].ToString();
         String City = iReader["City"] == DBNull.Value ? "" : iReader["City"].ToString();
         ddlCity.SelectedIndex = ddlCity.Items.IndexOf(ddlCity.Items.FindByValue(City.ToString()));
         String Statecd = iReader["State"] == DBNull.Value ? "" : iReader["State"].ToString();
         ddlState.SelectedIndex = ddlState.Items.IndexOf(ddlState.Items.FindByValue(Statecd.ToString()));
         //txtzip.Text = iReader["Zip"] == DBNull.Value ? "" : iReader["Zip"].ToString();
     }
 }
    private void BindMaterials()
    {
        DataSet dsGrp = new DataSet();
        Whitfieldcore wUser = new Whitfieldcore();
        dsGrp = wUser.GetAllMaterialTypes();
        if (dsGrp.Tables[0].Rows.Count > 0)
        {

            ddlType.DataSource = dsGrp;
            ddlType.DataTextField = "Mat_type_Desc";
            ddlType.DataValueField = "Mat_type_id";
            ddlType.DataBind();
            ddlType.Items.Insert(0, common.AddItemToList("Select Type", ""));

        }
    }
    private void BindEstimators()
    {
        DataSet dsGrp = new DataSet();
        Whitfieldcore wUser = new Whitfieldcore();
        dsGrp = wUser.GetEstimators();
        if (dsGrp.Tables[0].Rows.Count > 0)
        {

            ddlEstimator.DataSource = dsGrp;
            ddlEstimator.DataTextField = "estName";
            ddlEstimator.DataValueField = "Loginid";
            ddlEstimator.DataBind();
            ddlEstimator.Items.Insert(0, common.AddItemToList("Select Estimator", ""));

        }
    }
Beispiel #35
0
    private void sendEmail(String _estNum, String filenm, String IsFinancial)
    {
        Whitfieldcore _wcore = new Whitfieldcore();
        whitfielduser _wuser = new whitfielduser();

        using (DataSet dsContacts = _wcore.GetContactsForProject(Convert.ToInt32(_estNum)))
        {
            DataTable dtContacts = dsContacts.Tables[0];
            if (dtContacts.Rows.Count > 0)
            {
                foreach (DataRow dRow in dtContacts.Rows)
                {
                    String _contactNm     = dRow["contactName"] == DBNull.Value ? " " : dRow["contactName"].ToString();
                    String _contactEmail  = dRow["email"] == DBNull.Value ? " " : dRow["email"].ToString();
                    String _clientnm      = dRow["Name"] == DBNull.Value ? " " : dRow["Name"].ToString();
                    String _contactNumber = _wuser.GetContactNo(prjEsti);

                    String mode = "";
                    if (IsFinancial == "Y")
                    {
                        mode = "Proposal";
                    }
                    else
                    {
                        mode = "Scope";
                    }

                    //HHS Uncomment this portion when there is an email list.
                    MailMessage message = new MailMessage();

                    //message.To.Add(System.Configuration.ConfigurationManager.AppSettings["devEmail"]);

                    //message.To.Add(System.Configuration.ConfigurationManager.AppSettings["AdminEmail"].ToString());


                    message.To.Add(_contactEmail);                                                                       //This will be added once JW oks the function
                    message.To.Add(System.Configuration.ConfigurationManager.AppSettings["EstimatingEmail"].ToString()); //This is tested for contact Email, remove once JW oks the function.

                    message.From       = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["EstimatingEmail"]);
                    message.Subject    = txtprjname + " Architectural Millwork - WhitfieldCo - " + mode;
                    message.IsBodyHtml = true;

                    StringBuilder sb = new StringBuilder();
                    sb.Append("<html><head></head>");
                    sb.Append("<body>");


                    sb.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'><TR>");
                    sb.Append("<TD>");



                    sb.Append(_contactNm.Replace(",", " ") + ",<br>");
                    sb.Append("<br>Thank you for the opportunity to provide pricing on the " + txtprjname + " project for " + _clientnm + ". <br>");
                    sb.Append("<br>Please find attached our " + mode + " for the Custom Architectural Millwork which includes a complete and comprehensive scope for this work.<br>");
                    sb.Append("<br>You may contact me at " + _contactNumber + " with any questions regarding this estimate.<br>");
                    //sb.Append(<br>"_wuser.GetEstimatorName(prjEsti));
                    sb.Append("<br>" + txtNotes);
                    sb.Append("<br><br>" + _wuser.GetEstimatorName(prjEsti) + ",<br>");
                    sb.Append("Estimator");
                    sb.Append("<br><br>");
                    sb.Append("</TD>");
                    sb.Append("</TR></TABLE>");


                    //Footer
                    sb.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'><TR>");
                    sb.Append("<TD><IMG height='80' alt='' src='http://www.whitfield-co.com/whitfield-co/assets/img/TWC%20Primary%20Logo1.JPG' border='0'></TD></TR>");
                    sb.Append("<TR><TD class='form1' vAlign='bottom' align='left' width='100%'><b>The Whitfield Co., Inc.<br>");
                    sb.Append("8836 Washington Blvd., Ste 101<br>");
                    sb.Append("Jessup, MD 20794<br>");
                    sb.Append("(301)-483-0791<br>");
                    sb.Append("(301)-483-0792<br>");
                    sb.Append("http://www.whitfield-co.com<br>");
                    sb.Append("<IMG height='9' alt='' src='http://www.whitfield-co.com/whitfield-co/assets/img/images.gif' width='1'>");
                    sb.Append("</TD>");
                    sb.Append("</TR></TABLE>");
                    sb.Append("</body></html>");
                    message.Body = sb.ToString();

                    message.Attachments.Add(new System.Net.Mail.Attachment(HttpContext.Current.Server.MapPath("~/attachments/") + filenm));
                    SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["smtp"]);
                    smtp.Send(message);

                    if (!_contactEmail.Equals(""))
                    {
                        _wcore.InsertEmailConversation(Convert.ToInt32(_estNum), _contactEmail, _contactNm, DateTime.Now.ToString("MM-dd-yyyy"), DateTime.Now.ToString("T"), mode);
                    }
                }
            }
        }
    }
Beispiel #36
0
    //public void GeneratePDF(DataSet _ms)
    public void GeneratePDF(String EstNum, String IsFinancial)
    {
        Whitfieldcore _wc = new Whitfieldcore();
        // MemoryStream m = new MemoryStream();
        // Document document = new Document();
        FileStream MyStream = null;
        Document   document = new Document(PageSize.A4, 50, 50, 50, 50);

        try
        {
            iTextSharp.text.Font[] fonts = new iTextSharp.text.Font[16];
            fonts[0]  = FontFactory.GetFont(FontFactory.COURIER, 8, iTextSharp.text.Font.NORMAL);
            fonts[1]  = FontFactory.GetFont(FontFactory.COURIER, 8, iTextSharp.text.Font.BOLD);
            fonts[2]  = FontFactory.GetFont(FontFactory.COURIER, 8, iTextSharp.text.Font.ITALIC);
            fonts[3]  = FontFactory.GetFont(FontFactory.COURIER, 8, iTextSharp.text.Font.BOLD | iTextSharp.text.Font.ITALIC);
            fonts[4]  = FontFactory.GetFont(FontFactory.HELVETICA, 8, iTextSharp.text.Font.NORMAL);
            fonts[5]  = FontFactory.GetFont(FontFactory.HELVETICA, 8, iTextSharp.text.Font.BOLD);
            fonts[6]  = FontFactory.GetFont(FontFactory.HELVETICA, 8, iTextSharp.text.Font.ITALIC);
            fonts[7]  = FontFactory.GetFont(FontFactory.HELVETICA, 8, iTextSharp.text.Font.BOLD | iTextSharp.text.Font.ITALIC);
            fonts[8]  = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.NORMAL);
            fonts[9]  = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD);
            fonts[10] = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.ITALIC);
            fonts[11] = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD | iTextSharp.text.Font.ITALIC);
            fonts[12] = FontFactory.GetFont(FontFactory.SYMBOL, 10, iTextSharp.text.Font.NORMAL);
            fonts[13] = FontFactory.GetFont(FontFactory.ZAPFDINGBATS, 10, iTextSharp.text.Font.NORMAL);
            fonts[14] = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD | iTextSharp.text.Font.UNDERLINE, iTextSharp.text.Color.GRAY);
            fonts[15] = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.GRAY);

            // Response.ContentType = "application/pdf";
            // Response.AddHeader("content-disposition", "attachment;filename=Proposal_Document.pdf");
            //<Current Date> - <Project Name>, Architectural Millwork - WhitfieldCo
            //String _filename = DateTime.Now.ToString("MM-dd-yyyy") + "-"  + txtprjname  + ", Architectural Millwork - WhitfieldCo.pdf"
            //PdfWriter.GetInstance(document, new FileStream(_filename, FileMode.Create));
            //PdfWriter writer = PdfWriter.GetInstance(document, m);
            //writer.CloseStream = false;



            IDataReader iReader = _wc.GetProjectInfo(Convert.ToInt32(EstNum));
            while (iReader.Read())
            {
                txtprjname       = iReader["ProjName"] == DBNull.Value ? "" : iReader["ProjName"].ToString();
                lblPrjHeader     = iReader["ProjName"] == DBNull.Value ? "" : iReader["ProjName"].ToString();
                txtbasebid       = iReader["BaseBid"] == DBNull.Value ? "" : iReader["BaseBid"].ToString();
                txtfinalbid      = iReader["FinalPrice"] == DBNull.Value ? "" : iReader["FinalPrice"].ToString();
                txtdesc          = iReader["ProjDescr"] == DBNull.Value ? "" : iReader["ProjDescr"].ToString();
                txtNotes         = iReader["Notes"] == DBNull.Value ? "" : iReader["Notes"].ToString();
                txtBidDate       = iReader["BidDate"] == DBNull.Value ? "" : iReader["BidDate"].ToString();
                txtEditStartTime = iReader["BidTime"] == DBNull.Value ? "" : iReader["BidTime"].ToString();
                txtARDt          = iReader["AwardDur"] == DBNull.Value ? "" : iReader["AwardDur"].ToString();
                txtawardDate     = iReader["AwardDate"] == DBNull.Value ? "" : iReader["AwardDate"].ToString();
                txtConstStdate   = iReader["ConstrStart"] == DBNull.Value ? "" : iReader["ConstrStart"].ToString();
                txtConstDuration = iReader["ConstrDur"] == DBNull.Value ? "" : iReader["ConstrDur"].ToString();
                txtConstEndDate  = iReader["ConstrCompl"] == DBNull.Value ? DateTime.Now.ToString() : iReader["ConstrCompl"].ToString();
                //Adding New Fields
                txtfabEndDate   = iReader["fab_end"] == DBNull.Value ? "" : iReader["fab_end"].ToString();
                txtfabStartdate = iReader["fab_start"] == DBNull.Value ? "" : iReader["fab_start"].ToString();
                txtfabdurationt = iReader["fab_duration"] == DBNull.Value ? "" : iReader["fab_duration"].ToString();
                txtStreet       = iReader["prj_street"] == DBNull.Value ? "" : iReader["prj_street"].ToString();
                txtCity         = iReader["prj_city"] == DBNull.Value ? "" : iReader["prj_city"].ToString();
                txtState        = iReader["prj_state"] == DBNull.Value ? "" : iReader["prj_state"].ToString();
                txtzip          = iReader["prj_zip"] == DBNull.Value ? "" : iReader["prj_zip"].ToString();
                //New Fields Ends
                txtrealprjNumbert = iReader["Real_proj_Number"] == DBNull.Value ? "" : iReader["Real_proj_Number"].ToString();
                prjArch           = iReader["Architect"] == DBNull.Value ? "" : iReader["Architect"].ToString();
                prjEsti           = iReader["loginid"] == DBNull.Value ? "" : iReader["loginid"].ToString();
                txtTotCotCost     = iReader["Contengency"] == DBNull.Value ? "0" : iReader["Contengency"].ToString();
                txtEngRate        = iReader["enghourrate"] == DBNull.Value ? "45.00" : iReader["enghourrate"].ToString();
                txtFabRate        = iReader["fabhourrate"] == DBNull.Value ? "32.00" : iReader["fabhourrate"].ToString();
                txtInstRate       = iReader["insthourrate"] == DBNull.Value ? "45.00" : iReader["insthourrate"].ToString();
                txtMiscRate       = iReader["mischourrate"] == DBNull.Value ? "25.00" : iReader["mischourrate"].ToString();
                txtOverHeadRate   = iReader["overheadrate"] == DBNull.Value ? "24.11" : iReader["overheadrate"].ToString();
                txtMarkUpPercent  = iReader["profit_markup"] == DBNull.Value ? "15.00" : iReader["profit_markup"].ToString();
                txtDrawingDate    = iReader["drawingdate"] == DBNull.Value ? "" : iReader["drawingdate"].ToString();
                txtTypeOfWork     = iReader["typeofwork"] == DBNull.Value ? "" : iReader["typeofwork"].ToString();
            }

            Chunk chunkHeading;
            if (txtprjname.Length >= 30)
            {
                chunkHeading = new Chunk(txtprjname + "                                                                                                      ", fonts[15]);
            }
            else
            {
                chunkHeading = new Chunk(txtprjname + "                                                                                                                                      ", fonts[15]);
            }

            String _modetype = IsFinancial == "Y" ? "Proposal" : "Scope";

            Int32 _document_rev_number = GenerateseqNumberforDocs(Convert.ToInt32(EstNum), _modetype);

            _filename = DateTime.Now.ToString("MM-dd-yyyy") + "-" + txtprjname.Replace(".", " ").Trim() + " Architectural Millwork - WhitfieldCo " + _modetype + "-REV 0" + _document_rev_number + ".pdf";


            //if (File.Exists(HttpContext.Current.Server.MapPath("~/attachments/") + _filename))  //If the file exists, create new one.
            //{
            //    //File.Delete(HttpContext.Current.Server.MapPath("~/attachments/") + _filename);
            //    char[] splitchar = { '.' };
            //    string[] strArr = null;
            //    strArr = _filename.Split(splitchar);
            //    String _filenmTest = strArr[0];
            //    int intIndexSubstring = 0;
            //    intIndexSubstring = _filenmTest.IndexOf("-REV#");
            //    _filename = DateTime.Now.ToString("MM-dd-yyyy") + "-" + txtprjname.Replace(".", " ").Trim() + " Architectural Millwork - WhitfieldCo " + _modetype  +"-REV#0" + (Convert.ToInt32(_filenmTest.Substring(intIndexSubstring).Substring(5)) + 1).ToString() + ".pdf";

            //}
            //FileStream MyStream;
            //MyStream = new FileStream(HttpContext.Current.Server.MapPath("~/attachments/") + _filename, FileMode.Create);
            //PdfWriter.GetInstance(document, new FileStream(HttpContext.Current.Server.MapPath("~/attachments/") + _filename, FileMode.Create));
            //using (StreamWriter sw = File.CreateText(mappath + "patientquery.txt"))


            using (MyStream = new FileStream(HttpContext.Current.Server.MapPath("~/attachments/") + _filename, FileMode.Create))
            //using (FileStream MyStream = File.Create(HttpContext.Current.Server.MapPath("~/attachments/") + _filename))
            //new FileStream(HttpContext.Current.Server.MapPath("~/attachments/") + _filename, FileMode.Create)
            {
                PdfWriter.GetInstance(document, MyStream);
                //attachments
                document.AddAuthor("Whitfield Corporation");
                document.AddSubject("Proposal Generator");

                iTextSharp.text.Image img = this.DoGetImageFile(HttpContext.Current.Server.MapPath("~/assets/img/TWC Primary Logo1.JPG"));
                img.ScalePercent(50);
                Chunk ck = new Chunk(img, 0, -5);

                HeaderFooter headerRight = new HeaderFooter(new Phrase(chunkHeading), new Phrase(ck));
                document.Header       = headerRight;
                headerRight.Alignment = iTextSharp.text.Rectangle.ALIGN_RIGHT;
                headerRight.Border    = iTextSharp.text.Rectangle.NO_BORDER;


                // we Add a Footer that will show up on PAGE 1
                Phrase phFooter = new Phrase("The Whitfield Corporation, Incorporated  ", fonts[15]);
                phFooter.Add(new Phrase("P.O. Box 0385, Fulton, MD 20759  ", fonts[8]));
                phFooter.Add(new Phrase("Main: 301 483 0791 Fax: 301 483 0792  ", fonts[8]));
                phFooter.Add(new Phrase("\nDelivering on Promises", fonts[11]));
                //
                HeaderFooter footer = new HeaderFooter(phFooter, false);
                footer.Border    = iTextSharp.text.Rectangle.NO_BORDER;
                footer.Alignment = iTextSharp.text.Rectangle.ALIGN_CENTER;
                document.Footer  = footer;
                // step 3: we open the document
                document.Open();

                // we Add a Header that will show up on PAGE 2

                DateTime dt = DateTime.Now;
                //Chapters and Sections
                int ChapterSequence = 1;
                document.NewPage();
                iTextSharp.text.Font chapterFont    = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 16, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK);
                iTextSharp.text.Font sectionFont    = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLACK);
                iTextSharp.text.Font subsectionFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 14, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK);

                //Chapter 1 Overview
                Paragraph cTitle  = new Paragraph(_modetype, chapterFont);
                Chapter   chapter = new Chapter(cTitle, ChapterSequence);

                Paragraph ChapterDate = new Paragraph(dt.ToString("\nMMMM dd, yyyy \n\n"), fonts[8]);
                Paragraph ChapterRef  = new Paragraph("RE:   " + txtprjname + "\n\n", fonts[8]);

                Paragraph ChapterText1;

                if (txtTypeOfWork.Trim() == "Time & Material")
                {
                    ChapterText1 = new Paragraph("Whitfield proposes to complete the scope of work on a Time & Material basis per the rates included in the Item Breakdown section of this proposal.\n\n", fonts[8]);
                }
                else
                {
                    ChapterText1 = new Paragraph("Whitfield proposes to furnish all materials and perform all labor necessary, including " + txtTypeOfWork + ", to complete the following scope of work as per the Scope of Work breakdown.\n\n", fonts[8]);
                }

                String _fnlAmt          = "";
                String amtWithnoDecimal = "";

                if (txtbasebid != "")
                {
                    string[] txtBaseBidStr          = txtbasebid.Split('.');
                    custom.util.NumberToEnglish num = new custom.util.NumberToEnglish();
                    _fnlAmt          = num.changeCurrencyToWords(txtBaseBidStr[0].Replace("$", "").Trim());
                    amtWithnoDecimal = txtBaseBidStr[0] + ".00";
                }

                contingency _cont = new contingency();
                if (IsFinancial == "Y")
                {
                    Paragraph ChapterText2;
                    if (txtTypeOfWork.Trim() == "Time & Material")
                    {
                        ChapterText2 = new Paragraph("The Material cost in the amount of " + _fnlAmt + " Dollars and No Cents (" + Convert.ToDecimal(amtWithnoDecimal).ToString("C") + ") includes all profit markup and assumes a construction start on approximately " + Convert.ToDateTime(txtConstStdate).ToString("MMMM dd, yyyy") + " with a completion on or around " + Convert.ToDateTime(txtConstEndDate).ToString("MMMM dd, yyyy") + " .\n\n", fonts[8]);
                        //ChapterText2.Add(new Phrase(new Chunk("This cost is in addition to any Time & Material cost and will be calculated on a unit price basis as included in the Item Breakdown section of this proposal for any time extension beyond the agreed upon construction schedule as included in this proposal.\n\n", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.ITALIC | iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK))));
                    }
                    else
                    {
                        ChapterText2 = new Paragraph("This proposal assumes all of the above work completed by " + Convert.ToDateTime(txtConstEndDate).ToString("MMMM dd, yyyy") + " for the sum of ", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.ITALIC | iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK));
                        ChapterText2.Add(new Phrase(new Chunk(" " + _fnlAmt + "Dollars and No Cents (" + Convert.ToDecimal(amtWithnoDecimal).ToString("C") + ").\n\n", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.ITALIC | iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK))));
                    }


                    chapter.Add(ChapterDate);
                    chapter.Add(ChapterRef);
                    chapter.Add(ChapterText1);
                    chapter.Add(ChapterText2);

                    // Chapter Item Breakdown
                    DataSet dsCont = _cont.FetchProjectItemBreakdown(Convert.ToInt32(EstNum));
                    if (dsCont.Tables[0].Rows.Count > 0)
                    {
                        Paragraph cBreakDown = new Paragraph("Item Breakdown", chapterFont);
                        chapter.Add(cBreakDown);
                        DataTable myValues;
                        myValues = dsCont.Tables[0];
                        int icntBreakDown = 1;
                        foreach (DataRow dRow in myValues.Rows)
                        {
                            String    _cntlDesc        = dRow["Description"] == DBNull.Value ? "" : dRow["Description"].ToString();
                            String    _cntlAmt         = dRow["Amount"] == DBNull.Value ? "" : dRow["Amount"].ToString();
                            Paragraph itemAlternatives = new Paragraph(icntBreakDown.ToString() + ". " + _cntlDesc + "...." + _cntlAmt, fonts[8]);
                            icntBreakDown++;
                            chapter.Add(itemAlternatives);
                        }
                    }

                    // Chapter Alternatives
                    DataSet dsAlternatives = _cont.FetchAlternatives(Convert.ToInt32(EstNum));
                    if (dsAlternatives.Tables[0].Rows.Count > 0)
                    {
                        Paragraph c = new Paragraph("\nAlternates", fonts[14]);
                        chapter.Add(c);
                        DataTable myValues;
                        myValues = dsAlternatives.Tables[0];
                        int icntAlternatives = 1;
                        foreach (DataRow dRow in myValues.Rows)
                        {
                            String    _altType         = dRow["Type"] == DBNull.Value ? "" : dRow["Type"].ToString();
                            String    _cntlDesc        = dRow["Description"] == DBNull.Value ? "" : dRow["Description"].ToString();
                            String    _cntlAmt         = dRow["Amount"] == DBNull.Value ? "" : dRow["Amount"].ToString();
                            Paragraph itemAlternatives = new Paragraph(icntAlternatives.ToString() + ". " + _altType + ":" + _cntlDesc + "...." + _cntlAmt, fonts[8]);
                            icntAlternatives++;
                            chapter.Add(itemAlternatives);
                        }
                    }
                    //document.Add(chapter);
                    //Chapters and Sections Declarations End.
                }

                //**********************Chapter for Itemized Scope of Work Begins
                //ChapterSequence++;
                Paragraph cAssumptions = new Paragraph("\nItemized Scope of Work", chapterFont);
                chapter.Add(cAssumptions);
                //Chapter chapterAssumptions = new Chapter(cAssumptions, ChapterSequence);

                //Paragraph AssumptionsHeading = new Paragraph("Scope of Work\n\n", sectionFont);
                Paragraph AssumptionsText1 = new Paragraph("Provided hereto is an itemized clarification of the proposed scope. It has been developed and derived from the pricing documents to clarify various assumptions that were considered while compiling this estimate. The General Conditions (listed last) occur throughout the scope of work and apply to “typical applications”, which are subsequently itemized in the corresponding breakdown. " + ".\n\n", fonts[8]);
                //AssumptionsText1.Add(new Phrase(new Chunk("Proposed price includes " + txtTypeOfWork + ".\n\n", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK))));
                //chapterAssumptions.Add(AssumptionsHeading);
                chapter.Add(AssumptionsText1);

                DataSet dsScope = _wc.GetWorkOrders(EstNum);
                if (dsScope.Tables[0].Rows.Count > 0)
                {
                    LoadScopeOfWork(chapter, dsScope, fonts[14]);
                }

                Paragraph DrawingsPara1 = new Paragraph("Drawings:", fonts[14]);
                chapter.Add(DrawingsPara1);

                Paragraph itemDrawing = new Paragraph(txtprjname + " drawings prepared by " + _wc.GetArchitectName(Convert.ToInt32(prjArch)) + " dated " + txtDrawingDate + ".", fonts[8]);
                chapter.Add(itemDrawing);

                DataSet dsSpecs = _cont.FetchAmendmenList(Convert.ToInt32(EstNum));
                if (dsSpecs.Tables[0].Rows.Count > 0)
                {
                    Paragraph DrawingsPara = new Paragraph("\nAdditional Documents:", fonts[14]);
                    chapter.Add(DrawingsPara);
                    DataTable MyTerms;
                    MyTerms = dsSpecs.Tables[0];
                    int icntamendments = 1;
                    foreach (DataRow dRow in MyTerms.Rows)
                    {
                        String _AmedmentsType   = dRow["type"] == DBNull.Value ? "" : dRow["type"].ToString();
                        String _AmedmentNumber  = dRow["amendment_number"] == DBNull.Value ? "" : dRow["amendment_number"].ToString();
                        String _AmedmentDate    = dRow["amendment_date"] == DBNull.Value ? "" : dRow["amendment_date"].ToString();
                        String amendment_impact = dRow["amendment_impact"] == DBNull.Value ? "" : dRow["amendment_impact"].ToString();
                        //if (_AmedmentsType == "Amendment")
                        //{
                        if (amendment_impact.ToLower() == "yes")
                        {
                            Paragraph itemAmendment = new Paragraph(icntamendments.ToString() + ". " + _AmedmentsType + " " + _AmedmentNumber + " dated " + _AmedmentDate + " impacts this scope of work.", fonts[8]);
                            chapter.Add(itemAmendment);
                            //Amendment 001 dated 11/19/2010; This Amendment has no impact to this scope of work.
                        }
                        else
                        {
                            Paragraph itemAmendment = new Paragraph(icntamendments.ToString() + ". " + _AmedmentsType + " " + _AmedmentNumber + " dated " + _AmedmentDate + " does not impact this scope of work.", fonts[8]);
                            chapter.Add(itemAmendment);
                        }

                        //}
                        //else
                        //{
                        //    Paragraph itemAmendment = new Paragraph(icntamendments.ToString() + ". " + _AmedmentsType + " " + _AmedmentNumber + " " + _AmedmentDate, fonts[8]);
                        //    chapter.Add(itemAmendment);
                        //}

                        icntamendments++;
                    }
                }
                //Qualifications
                DataSet dsConditions = _wc.GetSpecExcl(Convert.ToInt32(EstNum));
                if (dsConditions.Tables[0].Rows.Count > 0)
                {
                    Paragraph DrawingsPara = new Paragraph("\nQualifications:", fonts[14]);
                    chapter.Add(DrawingsPara);
                    int       icnt = 1;
                    DataTable MyConditions;
                    MyConditions = dsConditions.Tables[0];
                    int tQualid = 0;
                    foreach (DataRow dRow in MyConditions.Rows)
                    {
                        if (Convert.ToInt32(dRow["qual_id"].ToString()) != tQualid)
                        {
                            Paragraph itemheading = new Paragraph(dRow["gName1"].ToString(), fonts[9]);
                            chapter.Add(itemheading);
                        }
                        String    _cntlDesc = dRow["description"] == DBNull.Value ? "" : dRow["description"].ToString();
                        Paragraph itemTerms = new Paragraph(icnt.ToString() + ".  " + _cntlDesc, fonts[8]);
                        chapter.Add(itemTerms);
                        tQualid = Convert.ToInt32(dRow["qual_id"].ToString());
                        icnt++;
                    }
                }

                // document.Add(chapter);
                //************************Chapter for Itemized Scope of Work Ends

                //*******Chapter Terms Begins********************
                //ChapterSequence++;
                Paragraph cTerms = new Paragraph("\nTerms", fonts[14]);
                //Chapter chapterTerms = new Chapter(cTerms, ChapterSequence);
                chapter.Add(cTerms);
                //Chapter chapterTerms = new Chapter(cTerms, ChapterSequence);
                DataSet dsTerms = _wc.GetTerms(Convert.ToInt32(EstNum));

                if (dsTerms.Tables[0].Rows.Count > 0)
                {
                    DataTable MyTerms;
                    MyTerms = dsTerms.Tables[0];
                    int icntTerms = 1;
                    foreach (DataRow dRow in MyTerms.Rows)
                    {
                        String    _cntlDesc = dRow["description"] == DBNull.Value ? "" : dRow["description"].ToString();
                        Paragraph itemTerms = new Paragraph(icntTerms.ToString() + ". " + _cntlDesc, fonts[8]);
                        chapter.Add(itemTerms);
                        icntTerms++;
                    }
                }


                Paragraph ChapterFooterText1 = new Paragraph("\nAll or part of the contract amount may be subject to change pending completion delay beyond agreed completion date and/or if changes to quantities are made. All agreements must be in writing prior to execution of any work.\n\n", fonts[8]);
                ChapterFooterText1.Add(Chunk.NEWLINE);
                ChapterFooterText1.Add(new Chunk("Respectfully submitted, ", fonts[8]));
                ChapterFooterText1.Add(new Chunk("                                                                  "));
                ChapterFooterText1.Add(new Chunk("Accepted By:, ", fonts[8]));
                ChapterFooterText1.Add(Chunk.NEWLINE);
                ChapterFooterText1.Add(new Chunk("The Whitfield Co., Inc., ", fonts[8]));
                ChapterFooterText1.Add(new Chunk("                                                                      "));
                ChapterFooterText1.Add(new Chunk("________________________ Date_________", fonts[8]));
                ChapterFooterText1.Add(Chunk.NEWLINE);
                ChapterFooterText1.Add(new Chunk("Jammie Whitfield, ", fonts[8]));
                ChapterFooterText1.Add(new Chunk("                                                                              "));
                ChapterFooterText1.Add(new Chunk("Name, Title", fonts[8]));
                //Paragraph ChapterFooterText2 = new Paragraph("Respectfully submitted,", fonts[8]);
                //Paragraph ChapterFooterText3 = new Paragraph("The Whitfield Co., Inc.\n\n", fonts[8]);
                //Paragraph ChapterFooterText4 = new Paragraph("Jammie Whitfield,", fonts[8]);
                //Paragraph ChapterFooterText5 = new Paragraph("Estimator", fonts[8]);

                chapter.Add(ChapterFooterText1);
                // Paragraph ChapterFooterText2 = new Paragraph("Respectfully submitted,", fonts[8]);
                // Paragraph ChapterFooterText3 = new Paragraph("The Whitfield Co., Inc.\n\n", fonts[8]);
                //Paragraph ChapterFooterText4 = new Paragraph("Jammie Whitfield,\n\n", fonts[8]);
                //Paragraph ChapterFooterText5 = new Paragraph("Accepted By:\n\n", fonts[8]);
                // Paragraph ChapterFooterText6 = new Paragraph("________________________ Date__________", fonts[8]);
                // Paragraph ChapterFooterText7 = new Paragraph("Name, Title", fonts[8]);

                chapter.Add(ChapterFooterText1);
                // chapter.Add(ChapterFooterText2);
                // chapter.Add(ChapterFooterText3);
                // chapter.Add(ChapterFooterText4);
                // chapter.Add(ChapterFooterText5);
                document.Add(chapter);

                //document.Add(new Chunk("Respectfully submitted, ", fonts[8]));
                //document.Add(new Chunk("                                                               "));
                //document.Add(new Chunk("Accepted By:, ", fonts[8]));
                //document.Add(Chunk.NEWLINE);
                //document.Add(new Chunk("The Whitfield Co., Inc., ", fonts[8]));
                //document.Add(new Chunk("                                                            "));
                //document.Add(new Chunk("________________________ Date_________", fonts[8]));
                //document.Add(Chunk.NEWLINE);
                //document.Add(new Chunk("Jammie Whitfield, ", fonts[8]));
                //document.Add(new Chunk("                                                                     "));
                //document.Add(new Chunk("Name, Title", fonts[8]));
                //*******Chapter Terms Ends********************
                document.Close();
                //MyStream.Flush();
                //MyStream.Close();
                //MyStream.Dispose();
                //}
                SetupEmailDocs(Convert.ToInt32(EstNum), _document_rev_number, _filename, _modetype);
                sendEmail(EstNum, _filename, IsFinancial);
            }
        }
        catch (DocumentException ex)
        {
            HttpResponse objResponse = HttpContext.Current.Response;
            objResponse.Write(ex.Message);
        }
        finally
        {
            if (MyStream != null)
            {
                MyStream.Close();
                MyStream.Dispose();
            }
        }

        //Response.Buffer = true;
        //Response.Clear();
        //Write pdf byes to outputstream
        //Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);
        //Response.OutputStream.Flush();
        //Response.End();
    }