625 lines
		
	
	
		
			25 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			625 lines
		
	
	
		
			25 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Data.SqlClient; | |||
|  | using System.Data; | |||
|  | using System.Linq; | |||
|  | using BLL; | |||
|  | using System.Text; | |||
|  | using AspNet = System.Web.UI.WebControls; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.HJGL.MaterialManage | |||
|  | { | |||
|  |     public partial class UsingPlan : PageBase | |||
|  |     { | |||
|  |         #region 加载页面 | |||
|  |         /// <summary> | |||
|  |         /// 加载页面 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); | |||
|  | 
 | |||
|  |                 string lastPlan = @"SELECT p.UsingPlanId FROM dbo.Weld_UsingPlan p 
 | |||
|  |                                     WHERE p.OrderDate<CONVERT(char(10),GetDate(),120)  | |||
|  |                                           AND p.IsCancel=0  | |||
|  |                                           AND (SELECT COUNT(*) FROM dbo.Weld_UsingMat u WHERE u.UsingPlanId=p.UsingPlanId)=0";
 | |||
|  |                 DataTable dt = SQLHelper.GetDataTableRunText(lastPlan, null); | |||
|  |                 if (dt.Rows.Count > 0) | |||
|  |                 { | |||
|  |                     for (int i = 0; i < dt.Rows.Count; i++) | |||
|  |                     { | |||
|  |                         string usingPlanId = dt.Rows[i]["UsingPlanId"].ToString(); | |||
|  |                         BLL.UsingPlanService.UpdateIsCancel(usingPlanId, "超时未领用"); | |||
|  |                     } | |||
|  |                 } | |||
|  | 
 | |||
|  |                 // 绑定表格 | |||
|  |                 BindGrid(); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 绑定数据 | |||
|  |         /// </summary> | |||
|  |         private void BindGrid() | |||
|  |         { | |||
|  |             string strSql = @"SELECT UsingPlan.UsingPlanId, UsingPlan.WeldId, UsingPlan.ProjectId, UsingPlan.UsePosition,team.TeamGroupName,UsingPlan.STE_Name,
 | |||
|  |                                      unit.UnitName AS UsingUnit,UsingPlan.Amount, UsingPlan.UsingManOne,  UsingPlan.InPutDate, | |||
|  |                                      UsingPlan.OrderDate,UsingPlan.OrderTime, UsingPlan.CancelDate,UsingPlan.IsNeedConfirm, | |||
|  |                                      (CASE UsingPlan.IsSteelStru WHEN 1 THEN '是' WHEN 0 THEN '否' ELSE '' END) AS IsSteelStru, | |||
|  |                                      (CASE UsingPlan.IsSubmit WHEN 1 THEN '是' WHEN 0 THEN '否' ELSE '' END) AS IsSubmit, | |||
|  |                                      (CASE UsingPlan.IsCancel WHEN 1 THEN '是' WHEN 0 THEN '否' ELSE '' END) AS IsCancel, | |||
|  |                                      Weld.ConsumablesCode,Weld.ConsumablesName,Weld.SteelFormat,Weld.WeldUnit,case Weld.ConsumablesType when '1' then '焊丝' when '2' then '焊条' when '3' then '焊剂' else '' end as WeldTypeName, | |||
|  |                                      Project.ProjectCode,Welder.WED_Name+'('+Welder.WED_Code+')' AS UsingManOneName,UsingPlan.IsSubmit AS WelderAudit, | |||
|  | 									 (CASE WHEN UsingPlan.InPutMan IS NOT NULL THEN (CASE WHEN userInput.UserName IS NOT NULL THEN userInput.UserName ELSE welderInput.WED_Name END) | |||
|  | 									           ELSE '' END) AS InPutMan, | |||
|  | 									 --man.UserName AS InPutMan, | |||
|  |                                      ((SELECT ISNULL(SUM(ISNULL(us.Amount,0)),0) FROM dbo.Weld_UsingMat us WHERE us.UsingPlanId=UsingPlan.UsingPlanId)- | |||
|  |                                      (SELECT ISNULL(SUM(ISNULL(re.RecycleAmount,0)),0) FROM dbo.Weld_RecycleMat re WHERE re.UsingPlanId=UsingPlan.UsingPlanId)) | |||
|  |                                      AS UsedAmount,(CASE UsingPlan.IsFinish WHEN 1 THEN '是' WHEN 0 THEN '否' ELSE NULL END) AS IsFinish | |||
|  |                               FROM dbo.Weld_UsingPlan AS UsingPlan | |||
|  |                                    LEFT JOIN dbo.Base_Consumables AS Weld ON Weld.ConsumablesId=UsingPlan.WeldId | |||
|  |                                    LEFT JOIN dbo.Base_Project AS Project ON Project.ProjectId =UsingPlan.ProjectId | |||
|  |                                    LEFT JOIN dbo.BS_Welder AS Welder ON Welder.WED_ID = UsingPlan.UsingManOne | |||
|  | 								   LEFT JOIN dbo.Base_Unit unit ON unit.UnitId=UsingPlan.UsingUnit | |||
|  | 								   LEFT JOIN dbo.Sys_User AS userInput ON userInput.UserId=UsingPlan.InPutMan | |||
|  | 								   LEFT JOIN dbo.BS_Welder AS welderInput ON welderInput.WED_ID=UsingPlan.InPutMan | |||
|  | 								   LEFT JOIN dbo.ProjectData_TeamGroup team ON team.TeamGroupId = UsingPlan.TeamGroupId | |||
|  |                              WHERE 1=1 ";
 | |||
|  |             List<SqlParameter> listStr = new List<SqlParameter>(); | |||
|  |             if (this.rblUsed.SelectedValue == "0") // 未领用 | |||
|  |             { | |||
|  |                 strSql += " AND IsCancel=0 AND (SELECT COUNT(*) FROM dbo.Weld_UsingMat u WHERE u.UsingPlanId=UsingPlan.UsingPlanId)=0 "; | |||
|  |             } | |||
|  |             else if (this.rblUsed.SelectedValue == "1") // 已领用 | |||
|  |             { | |||
|  |                 strSql += " AND (SELECT COUNT(*) FROM dbo.Weld_UsingMat u WHERE u.UsingPlanId=UsingPlan.UsingPlanId)>0 "; | |||
|  |             } | |||
|  |             else  // 已作废 | |||
|  |             { | |||
|  |                 strSql += " AND IsCancel=1"; | |||
|  |             } | |||
|  | 
 | |||
|  |             strSql += " AND UsingPlan.ProjectId = @ProjectId"; | |||
|  |             listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); | |||
|  |             if (!string.IsNullOrEmpty(this.txtWeldCode.Text.Trim())) | |||
|  |             { | |||
|  |                 strSql += " AND Weld.ConsumablesCode LIKE @ConsumablesCode"; | |||
|  |                 listStr.Add(new SqlParameter("@ConsumablesCode", "%" + this.txtWeldCode.Text.Trim() + "%")); | |||
|  |             } | |||
|  |             if (!string.IsNullOrEmpty(this.txtUsingMan.Text.Trim())) | |||
|  |             { | |||
|  |                 strSql += " AND Welder.WED_Name LIKE @UsingMan"; | |||
|  |                 listStr.Add(new SqlParameter("@UsingMan", "%" + this.txtUsingMan.Text.Trim() + "%")); | |||
|  |             } | |||
|  |             if (!string.IsNullOrEmpty(this.txtInputMan.Text.Trim())) | |||
|  |             { | |||
|  |                 strSql += " AND (CASE WHEN UsingPlan.InPutMan IS NOT NULL THEN (CASE WHEN userInput.UserName IS NOT NULL THEN userInput.UserName ELSE welderInput.WED_Name END) ELSE '' END) LIKE @InputMan"; | |||
|  |                 listStr.Add(new SqlParameter("@InputMan", "%" + this.txtInputMan.Text.Trim() + "%")); | |||
|  |             } | |||
|  |             if (!string.IsNullOrEmpty(this.txtUsingUnit.Text.Trim())) | |||
|  |             { | |||
|  |                 strSql += " AND unit.UnitName LIKE @UnitName"; | |||
|  |                 listStr.Add(new SqlParameter("@UnitName", "%" + this.txtUsingUnit.Text.Trim() + "%")); | |||
|  |             } | |||
|  |             //if (cbIsNeedConfirm.Checked) | |||
|  |             //{ | |||
|  |             //    strSql += " AND UsingPlan.IsNeedConfirm = 1"; | |||
|  |             //} | |||
|  | 
 | |||
|  |             SqlParameter[] parameter = listStr.ToArray(); | |||
|  |             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); | |||
|  | 
 | |||
|  |             Grid1.RecordCount = tb.Rows.Count; | |||
|  |             tb = GetFilteredTable(Grid1.FilteredData, tb); | |||
|  |             var table = this.GetPagedDataTable(Grid1, tb); | |||
|  |             Grid1.DataSource = table; | |||
|  |             Grid1.DataBind(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 查询 | |||
|  |         ///<summary> | |||
|  |         ///查询 | |||
|  |         ///</summary> | |||
|  |         ///<param name="sender"></param> | |||
|  |         ///<param name="e"></param> | |||
|  |         protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  | 
 | |||
|  |         protected void btnSelect_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  | 
 | |||
|  |         protected void rblUsed_SelectedIndexChanged(object sender, EventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) | |||
|  |         { | |||
|  |             if (e.CommandName == "ConfirmFinish") | |||
|  |             { | |||
|  |                 if (!string.IsNullOrEmpty(this.Grid1.SelectedRowID)) | |||
|  |                 { | |||
|  |                     var plan = BLL.UsingPlanService.GetUsingPlanById(this.Grid1.SelectedRowID); | |||
|  |                     if (plan.IsFinish == null || plan.IsFinish == false) | |||
|  |                     { | |||
|  |                         string window = String.Format("../../FingerMark/FingerConfirm.aspx?keyId={0}&flag=2&grid=4", this.Grid1.SelectedRowID, "编辑 - "); | |||
|  |                         PageContext.RegisterStartupScript(Window2.GetSaveStateReference(this.Grid1.SelectedRowID) | |||
|  |                           + Window2.GetShowReference(window)); | |||
|  |                     } | |||
|  |                     else | |||
|  |                     { | |||
|  |                         ShowNotify("该领料计划已完成"); | |||
|  |                     } | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) | |||
|  |         { | |||
|  |             DataRowView row = e.DataItem as DataRowView; | |||
|  |             //bool con = false; | |||
|  |             //if (row["IsNeedConfirm"].ToString()!="") | |||
|  |             //{ | |||
|  |             //    con= Convert.ToBoolean(row["IsNeedConfirm"]); | |||
|  |             //} | |||
|  |             //if (con) | |||
|  |             //{ | |||
|  |             //    e.RowCssClass = "color1"; | |||
|  |             //} | |||
|  | 
 | |||
|  |             //var plan = BLL.UsingPlanService.GetUsingPlanById(e.RowID); | |||
|  |             //if (plan != null) | |||
|  |             //{ | |||
|  |             //    var welder = BLL.HJGL_PersonManageService.GetWelderByWenId(plan.InPutMan); | |||
|  |             //    if (welder == null) | |||
|  |             //    { | |||
|  |             //        CheckBoxField cb = Grid1.FindColumn("WelderAudit") as CheckBoxField; | |||
|  |             //        e.CellCssClasses[cb.ColumnIndex] = "hidethis"; | |||
|  |             //    } | |||
|  |             //} | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         #region 表头过滤 | |||
|  |         protected void Grid1_FilterChange(object sender, EventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 页索引改变事件 | |||
|  |         /// <summary> | |||
|  |         /// 页索引改变事件 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) | |||
|  |         { | |||
|  |             Grid1.PageIndex = e.NewPageIndex; | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 排序 | |||
|  |         /// <summary> | |||
|  |         /// 排序 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Grid1_Sort(object sender, GridSortEventArgs e) | |||
|  |         { | |||
|  |             Grid1.SortDirection = e.SortDirection; | |||
|  |             Grid1.SortField = e.SortField; | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 分页选择下拉改变事件 | |||
|  |         /// <summary> | |||
|  |         /// 分页选择下拉改变事件 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) | |||
|  |         { | |||
|  |             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 弹出编辑窗口关闭事件 | |||
|  |         /// <summary> | |||
|  |         /// 弹出编辑窗体关闭事件 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Window1_Close(object sender, WindowCloseEventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 查询 | |||
|  |         /// <summary> | |||
|  |         /// 查询 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void TextBox_TextChanged(object sender, EventArgs e) | |||
|  |         { | |||
|  |             BindGrid(); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 增加按钮 | |||
|  |         /// <summary> | |||
|  |         /// 增加按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnNew_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CLGL_UsingPlanMenuId, BLL.Const.BtnAdd)) | |||
|  |             { | |||
|  |                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("UsingPlanEdit.aspx?UsingPlanId={0}", string.Empty, "编辑 - "))); | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 编辑 | |||
|  |         /// <summary> | |||
|  |         /// 双击Grid事件 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) | |||
|  |         { | |||
|  |             this.EditData(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 编辑按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnMenuEdit_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             this.EditData(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 编辑数据方法 | |||
|  |         /// </summary> | |||
|  |         private void EditData() | |||
|  |         { | |||
|  |             if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CLGL_UsingPlanMenuId, BLL.Const.BtnModify)) | |||
|  |             { | |||
|  |                 if (Grid1.SelectedRowIndexArray.Length == 0) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 string id = Grid1.SelectedRowID; | |||
|  |                 if (!string.IsNullOrEmpty(id)) | |||
|  |                 { | |||
|  |                     var usedMat = BLL.UsingMatService.GetUsingMatByPlanId(id); | |||
|  |                     if (usedMat == null) | |||
|  |                     { | |||
|  |                         PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("UsingPlanEdit.aspx?UsingPlanId={0}", id, "编辑 - "))); | |||
|  |                     } | |||
|  |                     else | |||
|  |                     { | |||
|  |                         Alert.ShowInTop("已有领用,不能修改!", MessageBoxIcon.Warning); | |||
|  |                         return; | |||
|  |                     } | |||
|  |                 } | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 复制按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnMenuCopy_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             this.CopyData(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 复制数据方法 | |||
|  |         /// </summary> | |||
|  |         private void CopyData() | |||
|  |         { | |||
|  |             if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CLGL_UsingPlanMenuId, BLL.Const.BtnModify)) | |||
|  |             { | |||
|  |                 if (Grid1.SelectedRowIndexArray.Length == 0) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 string id = Grid1.SelectedRowID; | |||
|  |                 if (!string.IsNullOrEmpty(id)) | |||
|  |                 { | |||
|  |                     var oldUsedPlan = BLL.UsingPlanService.GetUsingPlanById(id); | |||
|  |                     Model.Weld_UsingPlan usingPlan = new Model.Weld_UsingPlan(); | |||
|  |                     usingPlan.WeldId = oldUsedPlan.WeldId; | |||
|  |                     usingPlan.ProjectId = oldUsedPlan.ProjectId; | |||
|  |                     usingPlan.UsePosition = oldUsedPlan.UsePosition; | |||
|  |                     usingPlan.UsingUnit = oldUsedPlan.UsingUnit; | |||
|  |                     usingPlan.STE_ID = oldUsedPlan.STE_ID; | |||
|  |                     usingPlan.STE_Name = oldUsedPlan.STE_Name; | |||
|  |                     usingPlan.Amount = oldUsedPlan.Amount; | |||
|  |                     usingPlan.UsingManOne = oldUsedPlan.UsingManOne; | |||
|  |                     usingPlan.InPutDate = DateTime.Now; | |||
|  |                     usingPlan.OrderDate = DateTime.Now; | |||
|  |                     usingPlan.OrderTime = oldUsedPlan.OrderTime; | |||
|  |                     usingPlan.TeamGroupId = oldUsedPlan.TeamGroupId; | |||
|  |                     usingPlan.CancelDate = oldUsedPlan.CancelDate; | |||
|  |                     usingPlan.IsCancel = oldUsedPlan.IsCancel; | |||
|  |                     usingPlan.CancelResult = oldUsedPlan.CancelResult; | |||
|  |                     usingPlan.IsSubmit = oldUsedPlan.IsSubmit; | |||
|  |                     usingPlan.InPutMan = CurrUser.UserId; | |||
|  |                     usingPlan.IsSteelStru = oldUsedPlan.IsSteelStru; | |||
|  |                     usingPlan.Type = "1"; | |||
|  |                     usingPlan.UsingPlanId = SQLHelper.GetNewID(typeof(Model.Weld_UsingPlan)); | |||
|  |                     BLL.UsingPlanService.AddUsingPlan(usingPlan); | |||
|  |                     BLL.LogService.AddSys_Log(this.CurrUser, usingPlan.InPutDate.ToString(), usingPlan.UsingPlanId, BLL.Const.CLGL_UsingPlanMenuId, "拷贝领料计划录入"); | |||
|  |                     this.BindGrid(); | |||
|  |                     Alert.ShowInTop("拷贝成功!", MessageBoxIcon.Success); | |||
|  |                 } | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         protected void btnConfirm_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CLGL_UsingPlanMenuId, BLL.Const.BtnAuditing)) | |||
|  |             { | |||
|  |                 if (Grid1.SelectedRowIndexArray.Length == 0) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |                 string id = Grid1.SelectedRowID; | |||
|  |                 if (!string.IsNullOrEmpty(id)) | |||
|  |                 { | |||
|  |                     var noComfirm = BLL.UsingPlanService.GetUsingPlanById(id); | |||
|  |                     if (noComfirm.UsingUnit == CurrUser.UnitId) | |||
|  |                     { | |||
|  |                         if (noComfirm != null && noComfirm.IsNeedConfirm == true) | |||
|  |                         { | |||
|  |                             BLL.UsingPlanService.UpdateIsNeedConfirm(noComfirm.UsingPlanId, false); | |||
|  |                             Alert.ShowInTop("已审核确认!", MessageBoxIcon.Success); | |||
|  |                             BindGrid(); | |||
|  |                         } | |||
|  |                         else | |||
|  |                         { | |||
|  |                             Alert.ShowInTop("正常计划不用确认!", MessageBoxIcon.Warning); | |||
|  |                             return; | |||
|  |                         } | |||
|  |                     } | |||
|  |                     else | |||
|  |                     { | |||
|  |                         Alert.ShowInTop("非本单位数据,不能审核确认!", MessageBoxIcon.Warning); | |||
|  |                         return; | |||
|  |                     } | |||
|  | 
 | |||
|  |                 } | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 焊工录入计划审核 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnAudit_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CLGL_UsingPlanMenuId, BLL.Const.BtnAuditing)) | |||
|  |             { | |||
|  |                 bool selectItem = false; | |||
|  |                 CheckBoxField cb = Grid1.FindColumn("WelderAudit") as CheckBoxField; | |||
|  |                 for (int i = 0; i < Grid1.Rows.Count; i++) | |||
|  |                 { | |||
|  |                     string planId = Grid1.DataKeys[i][0].ToString(); | |||
|  |                     var plan = BLL.UsingPlanService.GetUsingPlanById(planId); | |||
|  |                     //var welder = BLL.HJGL_PersonManageService.GetWelderByWenId(plan.InPutMan); | |||
|  |                     //if (cb.GetCheckedState(i) == true && welder != null) | |||
|  |                     //{ | |||
|  |                     //    BLL.UsingPlanService.UpdateIsSubmit(planId); | |||
|  |                     //    selectItem = true; | |||
|  |                     //} | |||
|  |                 } | |||
|  |                 if (selectItem) | |||
|  |                 { | |||
|  |                     BindGrid(); | |||
|  |                     ShowNotify("所选记录已审核!", MessageBoxIcon.Success); | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     Alert.ShowInTop("请选择要审核的记录!", MessageBoxIcon.Warning); | |||
|  |                     return; | |||
|  |                 } | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         #region 删除 | |||
|  |         /// <summary> | |||
|  |         /// 右键删除事件 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         //protected void btnMenuDelete_Click(object sender, EventArgs e) | |||
|  |         //{ | |||
|  |         //    this.DeleteData(); | |||
|  |         //} | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 删除方法 | |||
|  |         /// </summary> | |||
|  |         private void DeleteData() | |||
|  |         { | |||
|  |             if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CLGL_UsingPlanMenuId, BLL.Const.BtnDelete)) | |||
|  |             { | |||
|  |                 if (Grid1.SelectedRowIndexArray.Length > 0) | |||
|  |                 { | |||
|  |                     bool isShow = false; | |||
|  |                     if (Grid1.SelectedRowIndexArray.Length == 1) | |||
|  |                     { | |||
|  |                         isShow = true; | |||
|  |                     } | |||
|  |                     foreach (int rowIndex in Grid1.SelectedRowIndexArray) | |||
|  |                     { | |||
|  |                         string rowID = Grid1.DataKeys[rowIndex][0].ToString(); | |||
|  |                         var plan = BLL.UsingPlanService.GetUsingPlanById(rowID); | |||
|  |                         if (this.judgementDelete(rowID, isShow)) | |||
|  |                         { | |||
|  |                             BLL.UsingPlanService.DeleteUsingPlanById(rowID); | |||
|  |                             BLL.LogService.AddSys_Log(this.CurrUser, plan.InPutDate.ToString(), rowID, BLL.Const.CLGL_UsingPlanMenuId, "删除领料计划录入"); | |||
|  |                         } | |||
|  |                     } | |||
|  |                     this.BindGrid(); | |||
|  |                     ShowNotify("删除数据成功!", MessageBoxIcon.Success); | |||
|  |                 } | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 判断是否可删除 | |||
|  |         /// </summary> | |||
|  |         /// <param name="rowID"></param> | |||
|  |         /// <param name="isShow"></param> | |||
|  |         /// <returns></returns> | |||
|  |         private bool judgementDelete(string rowID, bool isShow) | |||
|  |         { | |||
|  |             string content = string.Empty; | |||
|  |             if (string.IsNullOrEmpty(content)) | |||
|  |             { | |||
|  |                 return true; | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 if (isShow) | |||
|  |                 { | |||
|  |                     Alert.ShowInTop(content); | |||
|  |                 } | |||
|  |                 return false; | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 导入 | |||
|  |         /// <summary> | |||
|  |         /// 导入 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnImport_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("UsingPlanImport.aspx", "导入 - "))); | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 导出按钮 | |||
|  |         /// 导出按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnOut_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             Response.ClearContent(); | |||
|  |             string filename = Funs.GetNewFileName(); | |||
|  |             Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("领料计划" + filename, System.Text.Encoding.UTF8) + ".xls"); | |||
|  |             Response.ContentType = "application/excel"; | |||
|  |             Response.ContentEncoding = System.Text.Encoding.UTF8; | |||
|  |             Response.Write(GetGridTableHtml(Grid1)); | |||
|  |             Response.End(); | |||
|  |         } | |||
|  | 
 | |||
|  | #pragma warning disable CS0108 // “TrainRecord.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。 | |||
|  |         /// <summary> | |||
|  |         /// 导出方法 | |||
|  |         /// </summary> | |||
|  |         /// <param name="grid"></param> | |||
|  |         /// <returns></returns> | |||
|  |         private string GetGridTableHtml(Grid grid) | |||
|  | #pragma warning restore CS0108 // “TrainRecord.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。 | |||
|  |         { | |||
|  |             StringBuilder sb = new StringBuilder(); | |||
|  |             sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>"); | |||
|  |             sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">"); | |||
|  |             sb.Append("<tr>"); | |||
|  |             this.Grid1.PageSize = 100000; | |||
|  |             BindGrid(); | |||
|  |             foreach (GridColumn column in grid.Columns) | |||
|  |             { | |||
|  |                 if (column.ColumnIndex < 20) | |||
|  |                 { | |||
|  |                     sb.AppendFormat("<td>{0}</td>", column.HeaderText); | |||
|  |                 } | |||
|  |             } | |||
|  |             sb.Append("</tr>"); | |||
|  |             foreach (GridRow row in grid.Rows) | |||
|  |             { | |||
|  |                 sb.Append("<tr>"); | |||
|  |                 foreach (GridColumn column in grid.Columns) | |||
|  |                 { | |||
|  |                     if (column.ColumnIndex < 20) | |||
|  |                     { | |||
|  |                         string html = row.Values[column.ColumnIndex].ToString(); | |||
|  |                         if (column.ColumnID == "tfNumber") | |||
|  |                         { | |||
|  |                             html = (row.FindControl("lblNumber") as AspNet.Label).Text; | |||
|  |                         } | |||
|  |                         //sb.AppendFormat("<td>{0}</td>", html); | |||
|  |                         sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html); | |||
|  |                     } | |||
|  |                 } | |||
|  | 
 | |||
|  |                 sb.Append("</tr>"); | |||
|  |             } | |||
|  | 
 | |||
|  |             sb.Append("</table>"); | |||
|  | 
 | |||
|  |             return sb.ToString(); | |||
|  |         } | |||
|  |         #endregion | |||
|  |     } | |||
|  | } |