예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         Response.Cookies[Constants.ScreenName].Value = "Time Entry";
         if (!IsPostBack)
         {
             Response.Cookies[Constants.Update].Value = string.Empty;
             ViewState["Time"]         = string.Empty;
             ViewState["BillableUnit"] = string.Empty;
             GetDropdownValues();
             btnSubmit.Enabled = false;
             grvSearch.DataBind();
             string  sUserCode              = Convert.ToString(Request.Cookies[Constants.UserCode].Value);
             string  sCompanyCode           = Convert.ToString(Request.Cookies[Constants.CompanyCode].Value);
             DataSet ds                     = oTimeEntry.GetRecords(sUserCode, sCompanyCode);
             DataSet dsBillingConfigDetails = oTimeEntry.GetBillingConfigurationDetails(sUserCode, sCompanyCode);
             if (dsBillingConfigDetails != null && dsBillingConfigDetails.Tables.Count > 0)
             {
                 if (dsBillingConfigDetails.Tables[0].Rows.Count > 0)
                 {
                     ViewState["Time"]         = dsBillingConfigDetails.Tables[0].Rows[0]["Time"].ToString();
                     ViewState["BillableUnit"] = dsBillingConfigDetails.Tables[0].Rows[0]["BillableUnit"].ToString();
                     ViewState["HourlyRate"]   = dsBillingConfigDetails.Tables[0].Rows[0]["HourlyRate"].ToString();
                     btnSeach.Enabled          = true;
                 }
                 else
                 {
                     lblerror.Visible = true;
                     lblerror.Text    = "Billing Configuration is not Done for this company. Kindly Configure and Retry.";
                     btnSeach.Enabled = false;
                     return;
                 }
             }
             if (ds != null && ds.Tables[0].Rows.Count > 0)
             {
                 ViewState["Records"]         = ds.Tables[0];
                 ViewState["FilteredRecords"] = ds.Tables[0];
                 grvTimeEntry.DataSource      = ds.Tables[0];
                 grvTimeEntry.DataBind();
             }
             else
             {
                 grvTimeEntry.DataBind();
             }
         }
     }
     catch (Exception ex)
     {
         lblerror.Visible = true;
         lblerror.Text    = ex.Message.ToString();
     }
 }