/// <summary>
 /// 重新计算小时数
 /// </summary>
 private void ReCalculateHour(IEnumerable <LeaveRequestItem> leaveRequestItemList)
 {
     if (NotCalculate == false)
     {
         int i = 0;
         foreach (LeaveRequestItem item in leaveRequestItemList)
         {
             TextBox txtCaculate = (TextBox)gvLeaveRequestItemList.Rows[i].FindControl("txtCaculate");
             string  ans         = new CalculateLeaveRequestPresenter(item.FromDate.Date.ToString(),
                                                                      item.FromDate.Hour.ToString(),
                                                                      item.FromDate.Minute.ToString(),
                                                                      item.ToDate.Date.ToString(),
                                                                      item.ToDate.Hour.ToString(),
                                                                      item.ToDate.Minute.ToString(),
                                                                      Convert.ToInt32(hfEmployeeID.Value),
                                                                      Convert.ToInt32(ddlAbsentType.SelectedItem.Value)).GetHour();
             if (ans == "error")
             {
                 txtCaculate.Text = "0";
                 item.CostTime    = 0;
             }
             else
             {
                 txtCaculate.Text = ans;
                 item.CostTime    = Convert.ToDecimal(ans);
             }
             i++;
         }
     }
 }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ans =
                new CalculateLeaveRequestPresenter(Request.QueryString["FromDate"], Request.QueryString["FromHour"],
                                                   Request.QueryString["FromMinute"], Request.QueryString["ToDate"],
                                                   Request.QueryString["ToHour"], Request.QueryString["ToMinute"],
                                                   Convert.ToInt32(Request.QueryString["AccountID"]),
                                                   Convert.ToInt32(Request.QueryString["LeaveRequestTypeID"])).GetHour();

            Response.Write(ans);
            Response.End();
        }
 /// <summary>
 /// 计算小时
 /// </summary>
 /// <param name="leaveRequestItemList"></param>
 private void SetHour(IList <LeaveRequestItem> leaveRequestItemList)
 {
     if (NotCalculate == false)
     {
         decimal  allHour     = 0;
         DateTime minFromTime = leaveRequestItemList[0].FromDate;
         DateTime maxToTime   = leaveRequestItemList[0].ToDate;
         for (int i = 0; i < leaveRequestItemList.Count; i++)
         {
             string ans =
                 new CalculateLeaveRequestPresenter(leaveRequestItemList[i].FromDate.Date.ToString(),
                                                    leaveRequestItemList[i].FromDate.Hour.ToString(),
                                                    leaveRequestItemList[i].FromDate.Minute.ToString(),
                                                    leaveRequestItemList[i].ToDate.Date.ToString(),
                                                    leaveRequestItemList[i].ToDate.Hour.ToString(),
                                                    leaveRequestItemList[i].ToDate.Minute.ToString(),
                                                    Convert.ToInt32(hfEmployeeID.Value),
                                                    Convert.ToInt32(ddlAbsentType.SelectedItem.Value)).GetHour();
             TextBox   txtCaculate       = (TextBox)gvLeaveRequestItemList.Rows[i].FindControl("txtCaculate");
             HtmlImage imgResultCaculate =
                 (HtmlImage)gvLeaveRequestItemList.Rows[i].FindControl("imgResultCaculate");
             if (ans == "error")
             {
                 txtCaculate.Text      = "0";
                 imgResultCaculate.Src = "../../../Pages/image/wrong_icon.gif";
                 imgResultCaculate.Style["display"] = "block";
             }
             else
             {
                 txtCaculate.Text = ans;
                 imgResultCaculate.Style["display"] = "none";
             }
             allHour += Convert.ToDecimal(txtCaculate.Text);
             if (minFromTime > leaveRequestItemList[i].FromDate)
             {
                 minFromTime = leaveRequestItemList[i].FromDate;
             }
             if (maxToTime < leaveRequestItemList[i].ToDate)
             {
                 maxToTime = leaveRequestItemList[i].ToDate;
             }
         }
         lbCostTime.Text = string.Format("{0}小时", allHour);
         lbDate.Text     = string.Format("{0} ~ {1}", minFromTime, maxToTime);
     }
 }