Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserBL userBL = new UserBL();

               int cc =  Convert.ToInt32(Session["CompanyID"]);

               try
               {
               if (Request.QueryString["ShowPanel"] != null)
               {
                   if ((!IsPostBack))
                   {
                       Session["CompanyID"] = Convert.ToInt32(Session["CompanyID"]);
                   }
               }

               if (Session["CompanyID"] != null)
               {

                   Int32 companyid = Convert.ToInt32(Session["CompanyID"]);

                   if (companyid == 0)
                   {

                       Response.Redirect("~/UserLogin.aspx");

                   }
                   else if (companyid > 0)
                   {
                       CompanyDetailsView.ChangeMode(DetailsViewMode.Edit);
                       //CompanyDetailsView.AutoGenerateEditButton = true;

                   }

                   var bank = userBL.GetBankAccountByCompanyID();
                   if (bank.Count() > 0)
                   {
                       int bankaccountid = bank.ElementAt(0).BankAccountID;
                       if (bankaccountid == 0)
                       {
                           BankAccountDetailsView.ChangeMode(DetailsViewMode.Insert);
                       }
                       else if (bankaccountid > 0)
                       {
                           BankAccountDetailsView.ChangeMode(DetailsViewMode.Edit);
                       }
                   }
                   else
                   {
                       BankAccountDetailsView.ChangeMode(DetailsViewMode.Insert);
                   }

               }
               else
               {

                   Response.Redirect("~/UserLogin.aspx");
               }
               }
               catch (Exception ex)
               {
               throw ex;
               }
        }
Exemplo n.º 2
0
        protected void CompanyDetailsView_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
        {
            UserBL userBL = new UserBL();
            int bankid = 0;
            Int64 userid = Convert.ToInt32(HttpContext.Current.Session["UserID"]);
            var bank = userBL.GetBankAccountByCompanyID();
            if (bank.Count() > 0)
            {
                bankid = bank.ElementAt(0).BankAccountID;
            }
            if (bankid == 0)
            {
                bankid = Convert.ToInt32(Session["NewBankID"]);

            }

            e.NewValues["ModifiedBy"] = userid;
            e.NewValues["ModifiedTime"] = DateTime.Now;
            if (bankid == 0)
            {
                e.NewValues["BankAccount"] = null;
            }
            else if (bankid > 0)
            {
                e.NewValues["BankAccount"] = bankid;
            }

            if (Convert.ToInt32(countryDropDownList.SelectedValue) == 0) { e.NewValues["CountryID"] = null; }
            else { e.NewValues["CountryID"] = countryDropDownList.SelectedValue; }

            if (Convert.ToInt32(languageDropDownList.SelectedValue) == 0) { e.NewValues["LanguageID"] = null; }
            else { e.NewValues["LanguageID"] = languageDropDownList.SelectedValue; }

            if (Convert.ToInt32(currencyDropDownList.SelectedValue) == 0) { e.NewValues["CurrencyID"] = null; }
            else { e.NewValues["CurrencyID"] = currencyDropDownList.SelectedValue; }

            if (Convert.ToInt32(dateFormatDropDownList.SelectedValue) == 0) { e.NewValues["DateFormatID"] = null; }
            else { e.NewValues["DateFormatID"] = dateFormatDropDownList.SelectedValue; }

            if (Convert.ToInt32(timeFormatDropDownList.SelectedValue) == 0) { e.NewValues["TimeFormatID"] = null; }
            else { e.NewValues["TimeFormatID"] = timeFormatDropDownList.SelectedValue; }

            if (Convert.ToInt32(timeZoneDropDownList.SelectedValue) == 0) { e.NewValues["TimeZoneID"] = null; }
            else { e.NewValues["TimeZoneID"] = timeZoneDropDownList.SelectedValue; }

            if (Convert.ToInt32(companyTypesDropDownList.SelectedValue) == 0) { e.NewValues["CompanyTypeID"] = null; }
            else { e.NewValues["CompanyTypeID"] = companyTypesDropDownList.SelectedValue; }
        }