예제 #1
0
 protected void btnDisputeSend_OnClick(object sender, EventArgs e)
 {
     if (this.txtDisputeText.Text.Trim().Length > 0)
     {
         if (!string.IsNullOrEmpty(this.hfClientContactID.Value))
         {
             this.objEstimateDisputeHistoryBll.AddEstimateDisputeHistory(int.Parse(this.hfEstimateID.Value), "CompanyClientContact", int.Parse(this.hfClientContactID.Value), this.txtDisputeText.Text.Trim());
         }
         else
         {
             this.objEstimateDisputeHistoryBll.AddEstimateDisputeHistory(int.Parse(this.hfEstimateID.Value), "CompanyClient", int.Parse(this.hfClientID.Value), this.txtDisputeText.Text.Trim());
         }
         this.objEstimateMasterDT = this.objEstimateMasterBll.GetDataByEstimateID(int.Parse(this.hfEstimateID.Value));
         string str = this.objEstimateMasterDT.Rows[0]["EstimateStatus"].ToString();
         if (str.ToLower().Contains("sent") || str.ToLower().Contains("draft") || str.ToLower().Contains("viewed"))
         {
             this.objEstimateMasterBll.UpdateEstimateStatus("replied", int.Parse(this.hfEstimateID.Value));
         }
         this.Response.Redirect("ClientEstimate.aspx?cmd=view&ID=" + this.Request.QueryString["ID"]);
     }
     else
     {
         ScriptManager.RegisterClientScriptBlock(sender as Control, this.GetType(), "alert", "alert('You must provide a reason.')", true);
         this.txtDisputeText.Focus();
     }
 }
        private void ViewRecord(string id)
        {
            this.objEstimateMasterDT = this.objEstimateMasterBll.GetDataByEstimateID(int.Parse(id));
            if (this.objEstimateMasterDT.Rows.Count <= 0)
            {
                return;
            }
            this.hfCompanyID.Value       = this.objEstimateMasterDT.Rows[0]["CompanyID"].ToString();
            this.hfEstimateID.Value      = this.objEstimateMasterDT.Rows[0]["EstimateID"].ToString();
            this.lblEstimateNum.Text     = this.objEstimateMasterDT.Rows[0]["EstimateNumber"].ToString();
            this.lblEstimateNumHead.Text = "Estimate: " + this.objEstimateMasterDT.Rows[0]["EstimateNumber"];
            this.lblEstimateDate.Text    = DateTime.Parse(this.objEstimateMasterDT.Rows[0]["EstimateDate"].ToString()).ToString("MMMM dd, yyyy");
            this.lblPONumber.Text        = this.objEstimateMasterDT.Rows[0]["PONumber"].ToString();
            this.lblTerms.Text           = this.objEstimateMasterDT.Rows[0]["Terms"].ToString();
            this.lblNotes.Text           = this.objEstimateMasterDT.Rows[0]["Notes"].ToString();
            string s1 = this.objEstimateMasterDT.Rows[0]["Discount"].ToString();

            this.lblDiscout.Text           = s1.Length > 0 ? s1 : "0.00";
            this.lblEstimateTotalView.Text = Decimal.Round(Decimal.Parse(this.objEstimateMasterDT.Rows[0]["EstimateTotal"].ToString()), 2).ToString();
            this.lblPaidToDateView.Text    = Decimal.Round(Decimal.Parse(this.objEstimateMasterDT.Rows[0]["PaidToDate"].ToString()), 2).ToString();
            Label   label1 = this.lblEstimateAmount;
            Label   label2 = this.lblAmountDue;
            Decimal num1   = Decimal.Parse(this.lblEstimateTotalView.Text) - Decimal.Parse(this.lblPaidToDateView.Text);
            string  str1;
            string  str2 = str1 = num1.ToString();

            label2.Text = str1;
            string str3 = str2;

            label1.Text = str3;
            Label   label3 = this.lblEstimateAmount;
            Label   label4 = this.lblAmountDue;
            Decimal num2   = Decimal.Round(Decimal.Parse(this.lblAmountDue.Text), 2);
            string  str4;
            string  str5 = str4 = num2.ToString();

            label4.Text = str4;
            string str6 = str5;

            label3.Text = str6;
            this.divTaxValueView.Controls.Clear();
            this.divTaxView.Controls.Clear();
            Hashtable hashtable = new Hashtable();

            if (this.gvTaskView.Rows.Count > 0)
            {
                for (int index = 0; index < this.gvTaskView.Rows.Count; ++index)
                {
                    string text1 = this.gvTaskView.Rows[index].Cells[2].Text;
                    string text2 = this.gvTaskView.Rows[index].Cells[3].Text;
                    string text3 = this.gvTaskView.Rows[index].Cells[4].Text;
                    string text4 = this.gvTaskView.Rows[index].Cells[5].Text;
                    try
                    {
                        if (!string.IsNullOrEmpty(text3) && !text3.Contains("&"))
                        {
                            this.objTaxMasterDT = this.objTaxMasterBll.GetDataByTaxName(int.Parse(this.hfCompanyID.Value), text3);
                            if (this.objTaxMasterDT.Rows.Count > 0)
                            {
                                string  s2     = this.objTaxMasterDT.Rows[0]["TaxRate"].ToString();
                                Decimal d      = Decimal.Parse(text1) * Decimal.Parse(text2) * Decimal.Parse(s2) / new Decimal(100);
                                Label   label5 = new Label()
                                {
                                    Text = this.gvTaskView.Rows[index].Cells[4].Text + "(" + s2 + ")"
                                };
                                Label label6 = new Label()
                                {
                                    Text = string.Concat((object)Decimal.Round(d, 2))
                                };
                                if (hashtable.ContainsKey((object)label5.Text))
                                {
                                    object  obj  = hashtable[(object)label5.Text];
                                    Decimal num3 = d + Decimal.Parse(obj.ToString());
                                    hashtable.Remove((object)label5.Text);
                                    hashtable.Add((object)label5.Text, (object)num3.ToString());
                                }
                                else
                                {
                                    hashtable.Add((object)label5.Text, (object)label6.Text);
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(text4))
                        {
                            if (!text4.Contains("&"))
                            {
                                this.objTaxMasterDT = this.objTaxMasterBll.GetDataByTaxName(int.Parse(this.hfCompanyID.Value), text4);
                                if (this.objTaxMasterDT.Rows.Count > 0)
                                {
                                    string  s2     = this.objTaxMasterDT.Rows[0]["TaxRate"].ToString();
                                    Decimal d      = Decimal.Parse(text1) * Decimal.Parse(text2) * Decimal.Parse(s2) / new Decimal(100);
                                    Label   label5 = new Label()
                                    {
                                        Text = this.gvTaskView.Rows[index].Cells[5].Text + "(" + s2 + ")"
                                    };
                                    Label label6 = new Label()
                                    {
                                        Text = string.Concat((object)Decimal.Round(d, 2))
                                    };
                                    if (hashtable.ContainsKey((object)label5.Text))
                                    {
                                        object  obj  = hashtable[(object)label5.Text];
                                        Decimal num3 = d + Decimal.Parse(obj.ToString());
                                        hashtable.Remove((object)label5.Text);
                                        hashtable.Add((object)label5.Text, (object)num3.ToString());
                                    }
                                    else
                                    {
                                        hashtable.Add((object)label5.Text, (object)label6.Text);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        this.gvTaskView.Rows[index].Cells[4].Text = "";
                        this.gvTaskView.Rows[index].Cells[5].Text = "";
                    }
                }
            }
            if (this.gvItemView.Rows.Count > 0)
            {
                for (int index = 0; index < this.gvItemView.Rows.Count; ++index)
                {
                    string text1 = this.gvItemView.Rows[index].Cells[2].Text;
                    string text2 = this.gvItemView.Rows[index].Cells[3].Text;
                    string text3 = this.gvItemView.Rows[index].Cells[4].Text;
                    string text4 = this.gvItemView.Rows[index].Cells[5].Text;
                    try
                    {
                        if (!string.IsNullOrEmpty(text3) && !text3.Contains("&"))
                        {
                            this.objTaxMasterDT = this.objTaxMasterBll.GetDataByTaxName(int.Parse(this.hfCompanyID.Value), text3);
                            if (this.objTaxMasterDT.Rows.Count > 0)
                            {
                                string  s2     = this.objTaxMasterDT.Rows[0]["TaxRate"].ToString();
                                Decimal d      = Decimal.Parse(text1) * Decimal.Parse(text2) * Decimal.Parse(s2) / new Decimal(100);
                                Label   label5 = new Label()
                                {
                                    Text = this.gvItemView.Rows[index].Cells[4].Text + "(" + s2 + ")"
                                };
                                Label label6 = new Label()
                                {
                                    Text = string.Concat((object)Decimal.Round(d, 2))
                                };
                                if (hashtable.ContainsKey((object)label5.Text))
                                {
                                    object  obj  = hashtable[(object)label5.Text];
                                    Decimal num3 = d + Decimal.Parse(obj.ToString());
                                    hashtable.Remove((object)label5.Text);
                                    hashtable.Add((object)label5.Text, (object)num3.ToString());
                                }
                                else
                                {
                                    hashtable.Add((object)label5.Text, (object)label6.Text);
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(text4))
                        {
                            if (!text4.Contains("&"))
                            {
                                this.objTaxMasterDT = this.objTaxMasterBll.GetDataByTaxName(int.Parse(this.hfCompanyID.Value), text4);
                                if (this.objTaxMasterDT.Rows.Count > 0)
                                {
                                    string  s2     = this.objTaxMasterDT.Rows[0]["TaxRate"].ToString();
                                    Decimal d      = Decimal.Parse(text1) * Decimal.Parse(text2) * Decimal.Parse(s2) / new Decimal(100);
                                    Label   label5 = new Label()
                                    {
                                        Text = this.gvItemView.Rows[index].Cells[5].Text + "(" + s2 + ")"
                                    };
                                    Label label6 = new Label()
                                    {
                                        Text = string.Concat((object)Decimal.Round(d, 2))
                                    };
                                    if (hashtable.ContainsKey((object)label5.Text))
                                    {
                                        object  obj  = hashtable[(object)label5.Text];
                                        Decimal num3 = d + Decimal.Parse(obj.ToString());
                                        hashtable.Remove((object)label5.Text);
                                        hashtable.Add((object)label5.Text, (object)num3.ToString());
                                    }
                                    else
                                    {
                                        hashtable.Add((object)label5.Text, (object)label6.Text);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        this.gvItemView.Rows[index].Cells[4].Text = "";
                        this.gvItemView.Rows[index].Cells[5].Text = "";
                    }
                }
            }
            if (hashtable.Count > 0)
            {
                foreach (string str7 in (IEnumerable)hashtable.Keys)
                {
                    this.divTaxView.Controls.Add((Control) new Label()
                    {
                        Text = str7
                    });
                    this.divTaxView.Controls.Add((Control) new LiteralControl("<br />"));
                }
                foreach (object obj in (IEnumerable)hashtable.Values)
                {
                    this.divTaxValueView.Controls.Add((Control) new Label()
                    {
                        Text = ("+" + (object)Decimal.Round(Decimal.Parse(obj.ToString()), 2))
                    });
                    this.divTaxValueView.Controls.Add((Control) new LiteralControl("<br />"));
                }
            }
            Decimal d1 = new Decimal(0);

            if (this.gvItemView.Rows.Count > 0)
            {
                for (int index = 0; index < this.gvItemView.Rows.Count; ++index)
                {
                    string text = this.gvItemView.Rows[index].Cells[6].Text;
                    d1 += Decimal.Parse(text);
                }
            }
            if (this.gvTaskView.Rows.Count > 0)
            {
                for (int index = 0; index < this.gvTaskView.Rows.Count; ++index)
                {
                    string text = this.gvTaskView.Rows[index].Cells[6].Text;
                    d1 += Decimal.Parse(text);
                }
            }
            Label   label7 = this.lblSubTotalView;
            Decimal num4   = Decimal.Round(d1, 2);
            string  str8   = num4.ToString();

            label7.Text = str8;
            Label label8 = this.lblDiscountAmt;

            num4 = Decimal.Parse(this.lblSubTotalView.Text) * Decimal.Parse(s1) / new Decimal(100);
            string str9 = num4.ToString();

            label8.Text = str9;
            Label label9 = this.lblDiscountAmt;

            num4 = Decimal.Round(Decimal.Parse(this.lblDiscountAmt.Text), 2);
            string str10 = num4.ToString();

            label9.Text = str10;
            this.lblAddedTaxesView.Text = Decimal.Round(Decimal.Parse(this.lblEstimateAmount.Text) - Decimal.Parse(this.lblSubTotalView.Text) + Decimal.Parse(this.lblDiscountAmt.Text), 2).ToString();
            this.objCompanyMasterDT     = this.objCompanyMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            this.imgLogo.ImageUrl       = "../Handler/CompanyLogoFile.ashx?id=" + this.objCompanyMasterDT.Rows[0]["CompanyID"];
            this.lblCompanyName.Text    = this.objCompanyMasterDT.Rows[0]["CompanyName"].ToString();
            string str11 = string.Empty;

            if (!string.IsNullOrEmpty(this.objCompanyMasterDT.Rows[0]["CompanyAddressStreet1"].ToString()))
            {
                str11 = str11 + this.objCompanyMasterDT.Rows[0]["CompanyAddressStreet1"] + ",<br />";
            }
            if (!string.IsNullOrEmpty(this.objCompanyMasterDT.Rows[0]["CompanyAddressStreet2"].ToString()))
            {
                str11 = str11 + this.objCompanyMasterDT.Rows[0]["CompanyAddressStreet2"] + ",<br />";
            }
            if (!string.IsNullOrEmpty(this.objCompanyMasterDT.Rows[0]["CompanyCityID"].ToString()))
            {
                this.objCityMasterDT = this.objCityMasterBll.GetDataByCityID(int.Parse(this.objCompanyMasterDT.Rows[0]["CompanyCityID"].ToString()));
                if (this.objCityMasterDT.Rows.Count > 0)
                {
                    str11 = str11 + this.objCityMasterDT.Rows[0]["CityName"] + " - ";
                }
            }
            if (!string.IsNullOrEmpty(this.objCompanyMasterDT.Rows[0]["CompanyZipCode"].ToString()))
            {
                str11 = str11 + this.objCompanyMasterDT.Rows[0]["CompanyZipCode"] + ",<br />";
            }
            if (!string.IsNullOrEmpty(this.objCompanyMasterDT.Rows[0]["CompanyStateID"].ToString()))
            {
                this.objStateMasterDT = this.objStateMasterBll.GetDataByStateID(int.Parse(this.objCompanyMasterDT.Rows[0]["CompanyStateID"].ToString()));
                if (this.objStateMasterDT.Rows.Count > 0)
                {
                    str11 = str11 + this.objStateMasterDT.Rows[0]["StateName"] + ",<br />";
                }
            }
            if (!string.IsNullOrEmpty(this.objCompanyMasterDT.Rows[0]["CompanyCountryID"].ToString()))
            {
                this.objCountryMasterDT = this.objCountryMasterBll.GetDataByCountryID(int.Parse(this.objCompanyMasterDT.Rows[0]["CompanyCountryID"].ToString()));
                if (this.objCountryMasterDT.Rows.Count > 0)
                {
                    str11 = str11 + this.objCountryMasterDT.Rows[0]["CountryName"] + ".<br />";
                }
            }
            this.lblCompanyAddress.Text = str11;
            Label  label10 = this.lblCompanyAddress;
            string str12   = label10.Text + (object)"Email: <a href=\"mailto:" + (string)this.objCompanyMasterDT.Rows[0]["CompanyEmail"] + "\">" + (string)this.objCompanyMasterDT.Rows[0]["CompanyEmail"] + "</a><br />";

            label10.Text = str12;
            Label  label11 = this.lblCompanyAddress;
            string str13   = label11.Text + (object)"Phone: " + (string)this.objCompanyMasterDT.Rows[0]["CompanyPhone"];

            label11.Text = str13;
            this.objCompanyClientMasterDT       = this.objCompanyClientMasterBll.GetDataByCompanyClientID(int.Parse(this.objEstimateMasterDT.Rows[0]["ClientId"].ToString()));
            this.lblClientOrganizationName.Text = this.objCompanyClientMasterDT.Rows[0]["OrganizationName"].ToString();
            this.lblClientFullName.Text         = (string)this.objCompanyClientMasterDT.Rows[0]["FirstName"] + (object)" " + (string)this.objCompanyClientMasterDT.Rows[0]["LastName"];
            string str14 = string.Empty + this.objCompanyClientMasterDT.Rows[0]["Address1"] + ",<br />" + this.objCompanyClientMasterDT.Rows[0]["Address2"] + ",<br />";

            if (!string.IsNullOrEmpty(this.objCompanyClientMasterDT.Rows[0]["CityID"].ToString()))
            {
                this.objCityMasterDT = this.objCityMasterBll.GetDataByCityID(int.Parse(this.objCompanyClientMasterDT.Rows[0]["CityID"].ToString()));
                if (this.objCityMasterDT.Rows.Count > 0)
                {
                    str14 = str14 + this.objCityMasterDT.Rows[0]["CityName"] + " ";
                }
            }
            if (!string.IsNullOrEmpty(this.objCompanyClientMasterDT.Rows[0]["StateID"].ToString()))
            {
                this.objStateMasterDT = this.objStateMasterBll.GetDataByStateID(int.Parse(this.objCompanyClientMasterDT.Rows[0]["StateID"].ToString()));
                if (this.objStateMasterDT.Rows.Count > 0)
                {
                    str14 = str14 + this.objStateMasterDT.Rows[0]["StateName"] + " ";
                }
            }
            string str15 = string.Concat(new object[4]
            {
                (object)str14,
                (object)" - ",
                this.objCompanyClientMasterDT.Rows[0]["ZipCode"],
                (object)",<br />"
            });

            if (!string.IsNullOrEmpty(this.objCompanyClientMasterDT.Rows[0]["CountryID"].ToString()))
            {
                this.objCountryMasterDT = this.objCountryMasterBll.GetDataByCountryID(int.Parse(this.objCompanyClientMasterDT.Rows[0]["CountryID"].ToString()));
                str15 += this.objCountryMasterDT.Rows[0]["CountryName"].ToString();
            }
            this.lblClientAddress.Text = str15;
            switch (this.objEstimateMasterDT.Rows[0]["EstimateStatus"].ToString())
            {
            case "draft":
                this.divStatus.Attributes.Add("class", "status-draft");
                break;

            case "draft-partial":
                this.divStatus.Attributes.Add("class", "status-draft-partial");
                break;

            case "created":
                this.divStatus.Attributes.Add("class", "status-created");
                break;

            case "sent":
                this.divStatus.Attributes.Add("class", "status-received");
                break;

            case "viewed":
                this.divStatus.Attributes.Add("class", "status-received");
                break;

            case "disputed":
                this.divStatus.Attributes.Add("class", "status-disputed");
                break;

            case "paid":
                this.divStatus.Attributes.Add("class", "status-paid");
                break;

            case "partial":
                this.divStatus.Attributes.Add("class", "status-partial");
                break;

            case "pending":
                this.divStatus.Attributes.Add("class", "status-pending");
                break;

            case "declined":
                this.divStatus.Attributes.Add("class", "status-declined");
                break;

            case "auto-paid":
                this.divStatus.Attributes.Add("class", "status-auto-paid");
                break;

            case "retry":
                this.divStatus.Attributes.Add("class", "status-retry");
                break;

            case "failed":
                this.divStatus.Attributes.Add("class", "status-failed");
                break;

            case "replied":
                this.divStatus.Attributes.Add("class", "status-replied");
                break;

            case "commented":
                this.divStatus.Attributes.Add("class", "status-commented");
                break;

            case "resolved":
                this.divStatus.Attributes.Add("class", "status-resolved");
                break;

            case "invoiced":
                this.divStatus.Attributes.Add("class", "status-invoiced");
                break;

            case "accepted":
                this.divStatus.Attributes.Add("class", "status-accepted");
                break;

            case "Estimated":
                this.divStatus.Attributes.Add("class", "status-Estimated");
                break;

            case "outstanding":
                this.divStatus.Attributes.Add("class", "status-outstanding");
                break;

            case "open":
                this.divStatus.Attributes.Add("class", "status-open");
                break;

            default:
                this.divStatus.Attributes.Add("class", "status-created");
                break;
            }
            string s3 = this.objEstimateMasterDT.Rows[0]["CurrencyID"].ToString();

            if (string.IsNullOrEmpty(s3))
            {
                return;
            }
            this.objCurrencyMasterDT = this.objCurrencyMasterBll.GetDataByCurrencyID(int.Parse(s3));
            if (this.objCurrencyMasterDT.Rows.Count <= 0)
            {
                return;
            }
            this.lblCurCodeView1.Text   = this.lblCurCodeView2.Text = this.objCurrencyMasterDT.Rows[0]["CurrencyCode"].ToString();
            this.lblCurSymbolView1.Text = this.lblCurSymbolView2.Text = this.objCurrencyMasterDT.Rows[0]["CurrencySymbol"].ToString();
        }