public virtual CloudAccountDA.TemplateSettingsDataTable GetData()
 {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     CloudAccountDA.TemplateSettingsDataTable dataTable = new CloudAccountDA.TemplateSettingsDataTable();
     this.Adapter.Fill(dataTable);
     return(dataTable);
 }
 public virtual int Fill(CloudAccountDA.TemplateSettingsDataTable dataTable)
 {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if (this.ClearBeforeFill)
     {
         dataTable.Clear();
     }
     return(this.Adapter.Fill(dataTable));
 }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     this.objTemplateSettingsDT = this.objTemplateSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
     if (this.objTemplateSettingsDT.Rows.Count > 0)
     {
         this.objTemplateSettingsBll.UpdateTemplateSettings(int.Parse(this.hfTempalteID.Value), int.Parse(this.hfCompanyID.Value), 1, this.txtInvoiceTitle.Text.Trim(), this.txtEstimateTitle.Text.Trim(), this.txtCreditTitle.Text.Trim(), true);
     }
     else
     {
         this.objTemplateSettingsBll.AddTemplateSettings(int.Parse(this.hfCompanyID.Value), 1, this.txtInvoiceTitle.Text.Trim(), this.txtEstimateTitle.Text.Trim(), this.txtCreditTitle.Text.Trim(), true);
     }
     this.Session["saveTemp"] = (object)1;
     this.Response.Redirect("InvoiceTemplate.aspx");
 }
 public virtual CloudAccountDA.TemplateSettingsDataTable DeleteByTemplateID(int?TemplateID)
 {
     this.Adapter.SelectCommand = this.CommandCollection[2];
     if (TemplateID.HasValue)
     {
         this.Adapter.SelectCommand.Parameters[1].Value = TemplateID.Value;
     }
     else
     {
         this.Adapter.SelectCommand.Parameters[1].Value = DBNull.Value;
     }
     CloudAccountDA.TemplateSettingsDataTable dataTable = new CloudAccountDA.TemplateSettingsDataTable();
     this.Adapter.Fill(dataTable);
     return(dataTable);
 }
 private void SetCompanyRecords(string companyID)
 {
     this.objTemplateSettingsDT = this.objTemplateSettingsBll.GetDataByCompanyID(int.Parse(companyID));
     if (this.objTemplateSettingsDT.Rows.Count > 0)
     {
         this.hfTempalteID.Value     = this.objTemplateSettingsDT.Rows[0]["TemplateSettingsID"].ToString();
         this.hfCompanyID.Value      = this.objTemplateSettingsDT.Rows[0]["CompanyID"].ToString();
         this.txtInvoiceTitle.Text   = this.objTemplateSettingsDT.Rows[0]["InvoiceTitle"].ToString();
         this.txtEstimateTitle.Text  = this.objTemplateSettingsDT.Rows[0]["EstimateTitle"].ToString();
         this.txtCreditTitle.Text    = this.objTemplateSettingsDT.Rows[0]["CreditTitle"].ToString();
         this.chkPaymentStub.Checked = bool.Parse(this.objTemplateSettingsDT.Rows[0]["PaymentStub"].ToString());
     }
     else
     {
         this.objTemplateSettingsBll.AddTemplateSettings(int.Parse(this.hfCompanyID.Value), 1, "Invoice", "Estimate", "Credit", true);
         this.Response.Redirect("InvoiceTemplate.aspx");
     }
 }
Ejemplo n.º 6
0
        private void ViewRecord(string id)
        {
            bool flag = false;

            this.objEstimateMasterDT = this.objEstimateMasterBll.GetDataByEstimateID(int.Parse(id));
            if (this.objEstimateMasterDT.Rows.Count > 0)
            {
                flag = this.objEstimateMasterDT.Rows[0]["ClientID"].ToString() == this.hfClientID.Value;
            }
            if (this.objEstimateMasterDT.Rows.Count > 0 && flag)
            {
                this.hfCompanyID.Value     = this.objEstimateMasterDT.Rows[0]["CompanyID"].ToString();
                this.objTemplateSettingsDT = this.objTemplateSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
                if (this.objTemplateSettingsDT.Rows.Count > 0)
                {
                    this.lblEstimateTitle.Text     = (string)this.objTemplateSettingsDT.Rows[0]["EstimateTitle"] + (object)" #";
                    this.lblEstimateTitleDate.Text = (string)this.objTemplateSettingsDT.Rows[0]["EstimateTitle"] + (object)" Date";
                }
                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;
                string str7 = this.objEstimateMasterDT.Rows[0]["EstimateStatus"].ToString();
                if (str7.ToLower() == "sent")
                {
                    this.objEstimateMasterBll.UpdateEstimateStatus("viewed", int.Parse(this.hfEstimateID.Value));
                }
                this.dlHistory.DataBind();
                this.disputeDivLabel.Visible = this.dlHistory.Items.Count > 0;
                this.disputeDiv.Visible      = this.disputeDivLabel.Visible;
                this.btnAccept.Visible       = str7.ToLower() != "accepted";
                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 str8 in (IEnumerable)hashtable.Keys)
                    {
                        this.divTaxView.Controls.Add((Control) new Label()
                        {
                            Text = str8
                        });
                        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);
                    }
                }
                this.lblSubTotalView.Text   = Decimal.Round(d1, 2).ToString();
                this.lblDiscountAmt.Text    = (Decimal.Parse(this.lblSubTotalView.Text) * Decimal.Parse(s1) / new Decimal(100)).ToString();
                this.lblDiscountAmt.Text    = Decimal.Round(Decimal.Parse(this.lblDiscountAmt.Text), 2).ToString();
                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 str9 = string.Empty;
                if (!string.IsNullOrEmpty(this.objCompanyMasterDT.Rows[0]["CompanyAddressStreet1"].ToString()))
                {
                    str9 = str9 + this.objCompanyMasterDT.Rows[0]["CompanyAddressStreet1"] + ",<br />";
                }
                if (!string.IsNullOrEmpty(this.objCompanyMasterDT.Rows[0]["CompanyAddressStreet2"].ToString()))
                {
                    str9 = str9 + 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)
                    {
                        str9 = str9 + this.objCityMasterDT.Rows[0]["CityName"] + " - ";
                    }
                }
                if (!string.IsNullOrEmpty(this.objCompanyMasterDT.Rows[0]["CompanyZipCode"].ToString()))
                {
                    str9 = str9 + 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)
                    {
                        str9 = str9 + 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)
                    {
                        str9 = str9 + this.objCountryMasterDT.Rows[0]["CountryName"] + ".<br />";
                    }
                }
                this.lblCompanyAddress.Text = str9;
                Label  label7 = this.lblCompanyAddress;
                string str10  = label7.Text + (object)"Email: <a href=\"mailto:" + (string)this.objCompanyMasterDT.Rows[0]["CompanyEmail"] + "\">" + (string)this.objCompanyMasterDT.Rows[0]["CompanyEmail"] + "</a><br />";
                label7.Text = str10;
                Label  label8 = this.lblCompanyAddress;
                string str11  = label8.Text + (object)"Phone: " + (string)this.objCompanyMasterDT.Rows[0]["CompanyPhone"];
                label8.Text = str11;
                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 str12 = 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)
                    {
                        str12 = str12 + 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)
                    {
                        str12 = str12 + this.objStateMasterDT.Rows[0]["StateName"] + " ";
                    }
                }
                string str13 = string.Concat(new object[4]
                {
                    (object)str12,
                    (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()));
                    str13 += this.objCountryMasterDT.Rows[0]["CountryName"].ToString();
                }
                this.lblClientAddress.Text = str13;
                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();
            }
            else
            {
                this.pnlViewAll.Visible = true;
                this.pnlView.Visible    = false;
                this.BindGrid();
            }
        }
 public virtual int Update(CloudAccountDA.TemplateSettingsDataTable dataTable)
 {
     return(this.Adapter.Update(dataTable));
 }
        private void SetNewDefaultValues()
        {
            MembershipUser user = Membership.GetUser();

            if (user != null)
            {
                string str = user.ToString();
                if (Roles.IsUserInRole(str, "Admin"))
                {
                    this.objCompanyLoginMasterDT = this.objCompanyLoginMasterBll.GetDataByCompanyLoginName(str);
                    if (this.objCompanyLoginMasterDT.Rows.Count > 0)
                    {
                        this.hfCompanyID.Value = this.objCompanyLoginMasterDT.Rows[0]["CompanyID"].ToString();
                    }
                }
                else if (Roles.IsUserInRole(str, "Employee"))
                {
                    this.objStaffMasterDT = this.objStaffMasterBll.GetDataByStaffUserName(str);
                    if (this.objStaffMasterDT.Rows.Count > 0)
                    {
                        this.hfCompanyID.Value = this.objStaffMasterDT.Rows[0]["CompanyID"].ToString();
                    }
                }
            }
            int num = 30;

            this.objFreePackageSettingsDT = this.objFreePackageSettingsBll.GetAllDetail();
            if (this.objFreePackageSettingsDT.Rows.Count > 0)
            {
                num = int.Parse(this.objFreePackageSettingsDT.Rows[0]["FreePackageDays"].ToString());
            }
            this.objCompanyPackageMasterDT = this.objCompanyPackageMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objCompanyPackageMasterDT.Rows.Count == 0)
            {
                this.objCompanyPackageMasterBll.AddCompanyPackage(int.Parse(this.hfCompanyID.Value), 0, new DateTime?(DateTime.Now), new DateTime?(DateTime.Now.AddDays((double)num)), "FREE", new Decimal?(new Decimal(0)), "NONE", new DateTime?(), new DateTime?(DateTime.Now), true);
            }
            this.objAdminPermissionMasterDT = this.objAdminPermissionMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objAdminPermissionMasterDT.Rows.Count == 0)
            {
                this.objAdminPermissionMasterBll.AddAdminPermission(int.Parse(this.hfCompanyID.Value), true, true, true, false, false);
            }
            this.objMiscellaneousMasterDT = this.objMiscellaneousMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objMiscellaneousMasterDT.Rows.Count == 0)
            {
                this.objMiscellaneousMasterBll.AddMiscellaneous(int.Parse(this.hfCompanyID.Value), 15, "MM/dd/yyyy", true, true, true, "", true, false, "Both", "", "", "None", "Read/Write", 30, 10);
            }
            this.objClientPermissionMasterDT = this.objClientPermissionMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objClientPermissionMasterDT.Rows.Count == 0)
            {
                this.objClientPermissionMasterBll.AddClientPermission(int.Parse(this.hfCompanyID.Value), true, true, true, false, false, true, true);
            }
            this.objStaffPermissionMasterDT = this.objStaffPermissionMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objStaffPermissionMasterDT.Rows.Count == 0)
            {
                this.objStaffPermissionMasterBll.AddStaffPermission(int.Parse(this.hfCompanyID.Value), true, true, true, true, true, false, false, true, true, true, true, true);
            }
            this.objTemplateSettingsDT = this.objTemplateSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objTemplateSettingsDT.Rows.Count == 0)
            {
                this.objTemplateSettingsBll.AddTemplateSettings(int.Parse(this.hfCompanyID.Value), 1, "Invoice", "Estimate", "Credit", true);
            }
            this.objEmailNotificationsDT = this.objEmailNotificationsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objEmailNotificationsDT.Rows.Count == 0)
            {
                this.objEmailNotificationsBll.AddEmailNotifications(int.Parse(this.hfCompanyID.Value), true, false, false, false);
            }
            this.objSMTPSettingsDT = this.objSMTPSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objSMTPSettingsDT.Rows.Count == 0)
            {
                this.objSMTPSettingsBll.AddSMTPSettings(int.Parse(this.hfCompanyID.Value), Common.CommonHandler.BaseMailFrom, Common.CommonHandler.BaseHost, Convert.ToInt32(Common.CommonHandler.BasePort), Common.CommonHandler.BaseEnableSSL, Common.CommonHandler.BasePassword, Common.CommonHandler.BaseUserName, "Best regards,<br />##companyName## (##companyEmail##)");
            }
            this.objNewClientEmailTemplateDT = this.objNewClientEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objNewClientEmailTemplateDT.Rows.Count == 0)
            {
                this.objNewClientEmailTemplateBll.AddClientTemplate(int.Parse(this.hfCompanyID.Value), "##companyName## is now invoicing you with Bill Transact", new StringBuilder("Welcome to ##companyName##'s secure online services.  An account has been created for you.<br />To securely access your account, go to:<br />##login link##<br />Login using the following username and password:<br />Username: ##username##<br />Password: ##password##<br />").ToString());
            }
            this.objNewCreditEmailTemplateDT = this.objNewCreditEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objNewCreditEmailTemplateDT.Rows.Count == 0)
            {
                this.objNewCreditEmailTemplateBll.AddCreditTemplate(int.Parse(this.hfCompanyID.Value), "New Credit ##creditNumber## from ##companyName## , sent using Bill Transact", new StringBuilder("You have received credit in the amount of ##paymentAmt##. To view it and download a PDF copy for your records, click the link below.<br /><br />##creditLink##<br />").ToString());
            }
            this.objNewEstimateEmailTemplateDT = this.objNewEstimateEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objNewEstimateEmailTemplateDT.Rows.Count == 0)
            {
                this.objNewEstimateEmailTemplateBll.AddEstimateTemplate(int.Parse(this.hfCompanyID.Value), "New Estimate ##estimateNumber## from ##companyName## , sent using Bill Transact", new StringBuilder("To access your estimate from ##companyName## for ##paymentAmt##, go to:<br /><br /> ##estimateLink##<br />").ToString());
            }
            this.objNewInvoiceEmailTemplateDT = this.objNewInvoiceEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objNewInvoiceEmailTemplateDT.Rows.Count == 0)
            {
                this.objNewInvoiceEmailTemplateBll.AddInvoiceTemplate(int.Parse(this.hfCompanyID.Value), "New invoice ##invoiceNumber## from ##companyName## , sent using Bill Transact", new StringBuilder("To view your invoice from ##companyName## for ##invoiceAmt##, or to download a PDF copy for your records, click the link below:<br /><br />##someLink##<br /><br />").ToString());
            }
            this.objNewStaffEmailTemplateDT = this.objNewStaffEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objNewStaffEmailTemplateDT.Rows.Count == 0)
            {
                this.objNewStaffEmailTemplateBll.AddStaffTemplate(int.Parse(this.hfCompanyID.Value), "##companyName## invites you to track time and expenses in Bill Transact", new StringBuilder("You are now part of ##companyName##'s team.<br />Click here to log in to your account:<br />##login link##<br /><br />Username: ##username##<br />Password: ##password##<br />").ToString());
            }
            this.objNewPaymentEmailTemplateDT = this.objNewPaymentEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "online");
            if (this.objNewPaymentEmailTemplateDT.Rows.Count == 0)
            {
                this.objNewPaymentEmailTemplateBll.AddPaymentTemplate(int.Parse(this.hfCompanyID.Value), "online", true, "##companyName## has received your payment for invoice ##invoiceNumber## in Bill Transact", new StringBuilder("Thank you for your business.<br />We have received your payment in the amount of ##payment amount## for invoice ##invoice number##.<br />To view the paid invoice or download a PDF copy for your records, click the link below:<br /><br />##someLink##<br />").ToString());
            }
            this.objNewPaymentEmailTemplateDT = this.objNewPaymentEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "other");
            if (this.objNewPaymentEmailTemplateDT.Rows.Count == 0)
            {
                this.objNewPaymentEmailTemplateBll.AddPaymentTemplate(int.Parse(this.hfCompanyID.Value), "other", false, "##companyName## has received your payment for invoice ##invoiceNumber## in Bill Transact", new StringBuilder("Thank you for your business.<br />We have received your payment in the amount of ##payment amount## for invoice ##invoice number##.<br />To view the paid invoice or download a PDF copy for your records, click the link below:<br /><br />##someLink##<br />").ToString());
            }
            this.objLatePaymentReminderTemplateDT = this.objLatePaymentReminderTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), 1);
            if (this.objLatePaymentReminderTemplateDT.Rows.Count == 0)
            {
                this.objLatePaymentReminderTemplateBll.AddLatePaymentReminder(int.Parse(this.hfCompanyID.Value), 1, false, 30, "Your payment for invoice ##invoiceNumber## is overdue in Bill Transact", new StringBuilder("Your invoice is now 30 days overdue.  Please pay your invoice.<br /><br />To access your invoice from ##companyName##, go to:<br /><br />##someLink##<br />").ToString());
            }
            this.objLatePaymentReminderTemplateDT = this.objLatePaymentReminderTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), 2);
            if (this.objLatePaymentReminderTemplateDT.Rows.Count == 0)
            {
                this.objLatePaymentReminderTemplateBll.AddLatePaymentReminder(int.Parse(this.hfCompanyID.Value), 2, false, 60, "Your payment for invoice ##invoiceNumber## is overdue in Bill Transact", new StringBuilder("Your invoice is now 60 days overdue.  Please pay your invoice.<br /><br />To access your invoice from ##companyName##, go to:<br /><br />##someLink##<br />").ToString());
            }
            this.objLatePaymentReminderTemplateDT = this.objLatePaymentReminderTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), 3);
            if (this.objLatePaymentReminderTemplateDT.Rows.Count == 0)
            {
                this.objLatePaymentReminderTemplateBll.AddLatePaymentReminder(int.Parse(this.hfCompanyID.Value), 3, false, 90, "Your payment for invoice ##invoiceNumber## is overdue in Bill Transact", new StringBuilder("Your invoice is now 90 days overdue.  Please pay your invoice.<br /><br />To access your invoice from ##companyName##, go to:<br /><br />##someLink##<br />").ToString());
            }
            this.objAutoBillEmailTemplateDT = this.objAutoBillEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "Auto-bill");
            if (this.objAutoBillEmailTemplateDT.Rows.Count == 0)
            {
                this.objAutoBillEmailTemplateBll.AddAutoBillEmail(int.Parse(this.hfCompanyID.Value), "Auto-bill", true, "New recurring invoice ##invoiceNumber## from ##companyName##, sent using Bill Transact", this.strBodyBill.ToString());
            }
            this.objAutoBillEmailTemplateDT = this.objAutoBillEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "Auto-paid");
            if (this.objAutoBillEmailTemplateDT.Rows.Count == 0)
            {
                this.objAutoBillEmailTemplateBll.AddAutoBillEmail(int.Parse(this.hfCompanyID.Value), "Auto-paid", true, "New recurring invoice ##invoiceNumber## from ##companyName##, sent using Bill Transact", this.strBodyPaid.ToString());
            }
            this.objAutoBillEmailTemplateDT = this.objAutoBillEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "Card Expired");
            if (this.objAutoBillEmailTemplateDT.Rows.Count == 0)
            {
                this.objAutoBillEmailTemplateBll.AddAutoBillEmail(int.Parse(this.hfCompanyID.Value), "Card Expired", true, "Action required: Your credit card on file with ##companyName## is expiring soon in Bill Transact", this.strBodyExpired.ToString());
            }
            this.objAutoBillEmailTemplateDT = this.objAutoBillEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "Card Failed");
            if (this.objAutoBillEmailTemplateDT.Rows.Count != 0)
            {
                return;
            }
            this.objAutoBillEmailTemplateBll.AddAutoBillEmail(int.Parse(this.hfCompanyID.Value), "Card Failed", false, "Action required: Your credit card on file for invoice ##invoiceNumber## from ##companyName## needs updating in Bill Transact", this.strBodyFailed.ToString());
        }