You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
401 lines
15 KiB
401 lines
15 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
using CK.SCP.Models.Enums;
|
|
using CK.SCP.Models.ScpEntity;
|
|
using CK.SCP.Utils;
|
|
using CK.SCP.Controller;
|
|
using FineUI;
|
|
using System.IO;
|
|
using CK.SCP.Models.ScpEntity.ExcelImportEntity;
|
|
|
|
namespace SCP.Views.沈阳金杯.PlanData
|
|
{
|
|
public partial class SCP_ASK : PageBase
|
|
{
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
|
|
LoadData();
|
|
|
|
}
|
|
}
|
|
public void LoadData()
|
|
{
|
|
if (!CurrentUser.RoleList.Contains("采购人员"))
|
|
{
|
|
Alert.Show("当前用户角色不能操作该模块!");
|
|
return;
|
|
}
|
|
if (CurrentUser.FactoryList==null || CurrentUser.FactoryList.Count == 0)
|
|
{
|
|
Alert.Show("当前用户未选择地点!");
|
|
return;
|
|
}
|
|
|
|
BindAsk();
|
|
}
|
|
public void BindAsk()
|
|
{
|
|
highlightRows.Text = "";
|
|
SearchV_TB_ASKData((result) => {
|
|
Grid_V_TB_ASK.RecordCount = result.Count();
|
|
var list = SortAndPage<V_TB_ASK>(result, Grid_V_TB_ASK);
|
|
var list_can = SCP_ASK_CONTROLLER.LOAD_ASK_DETAIL_CAN(list.ToList());
|
|
Grid_V_TB_ASK.DataSource = list_can;
|
|
Grid_V_TB_ASK.DataBind();
|
|
});
|
|
|
|
}
|
|
|
|
public void SearchV_TB_ASKData(Action<IQueryable<V_TB_ASK>> p_action)
|
|
{
|
|
V_TB_ASK _entity = new V_TB_ASK();
|
|
_entity.IsDeleted = false;
|
|
_entity.PoBillNum = TXT_BillNo.Text;
|
|
_entity.VendName = TXT_VendName.Text;
|
|
_entity.Site_Desc = TXT_Site_Desc.Text;
|
|
_entity.AskBillNum = TXT_AskBillNo.Text;
|
|
if (DP_StartDate.SelectedDate != null)
|
|
{
|
|
_entity.BeginTime = DP_StartDate.SelectedDate;
|
|
}
|
|
if (DP_StartDate_End.SelectedDate != null)
|
|
{
|
|
DateTime BeginTime_End = new DateTime();
|
|
if (DateTime.TryParse(DP_StartDate_End.SelectedDate.ToString(), out BeginTime_End))
|
|
{
|
|
_entity.BeginTime_End = BeginTime_End.AddHours(23).AddMinutes(59).AddSeconds(59);
|
|
}
|
|
}
|
|
if (Date_EndDate_Start.SelectedDate != null)
|
|
{
|
|
_entity.EndTime_start = Date_EndDate_Start.SelectedDate;
|
|
}
|
|
if (Date_EndDate.SelectedDate != null)
|
|
{
|
|
DateTime EndTime = new DateTime();
|
|
if (DateTime.TryParse(Date_EndDate.SelectedDate.ToString(), out EndTime))
|
|
{
|
|
_entity.EndTime = EndTime.AddHours(23).AddMinutes(59).AddSeconds(59);
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(DDL_State.SelectedValue))
|
|
{
|
|
_entity.BillStateList = new List<int>() { int.Parse(DDL_State.SelectedValue) };
|
|
}
|
|
if (!string.IsNullOrEmpty(CurrentUser.Name))
|
|
{
|
|
if (CurrentUser.Name != "admin"&& !CurrentUser.RoleList.Contains("采购部门主管"))
|
|
{
|
|
if (CurrentUser.FactoryList != null && CurrentUser.FactoryList.Count > 0)
|
|
{
|
|
|
|
if (CurrentUser.FactoryList.FirstOrDefault() == "0210")
|
|
{
|
|
if (!CurrentUser.RoleList.Contains("要货看板所有记录"))
|
|
{
|
|
_entity.CreateUser = CurrentUser.Name;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
_entity.UserInAddress = CurrentUser.FactoryList;
|
|
SCP_ASK_CONTROLLER.Get_V_TB_ASK_List(_entity, (_ret) =>
|
|
{
|
|
if (_ret.State == ReturnStatus.Succeed)
|
|
{
|
|
p_action(_ret.Result);
|
|
}
|
|
});
|
|
}
|
|
|
|
protected void Grid_V_TB_ASK_RowDoubleClick(object sender, FineUI.GridRowClickEventArgs e)
|
|
{
|
|
object[] rowDataKeys = Grid_V_TB_ASK.DataKeys[e.RowIndex];
|
|
string AskBillNum = rowDataKeys[2] as string;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(string.Format("../PlanData/SCP_ASK_DETAIL.aspx?AskBillNum={0}", AskBillNum))+ Window1.GetMaximizeReference());
|
|
}
|
|
|
|
protected void Grid_V_TB_ASK_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
Grid_V_TB_ASK.SortDirection = e.SortDirection;
|
|
Grid_V_TB_ASK.SortField = e.SortField;
|
|
BindAsk();
|
|
}
|
|
|
|
|
|
protected void Grid_V_TB_ASK_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindAsk();
|
|
}
|
|
|
|
protected void btnOutput_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid_V_TB_ASK.SelectedRowIndexArray.Count() == 0)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("没有选择数据!"));
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
List<string> _ls = new List<string>();
|
|
for (int i = 0, count = Grid_V_TB_ASK.Rows.Count; i < count; i++)
|
|
{
|
|
if (Grid_V_TB_ASK.SelectedRowIndexArray.Contains(i))
|
|
{
|
|
object[] rowDataKeys = Grid_V_TB_ASK.DataKeys[i];
|
|
_ls.Add(rowDataKeys[2] as string);
|
|
}
|
|
}
|
|
DataSet ds = SCP_EXCEL_CONTROLLER.GET_ASK_EXECEL(_ls);
|
|
PageBase.DataSetToExcel(ds, "要货看板");
|
|
|
|
}
|
|
|
|
protected void btnDetail_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid_V_TB_ASK.SelectedRowIndexArray.Count() == 0)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("没有选择数据!"));
|
|
return;
|
|
|
|
}
|
|
object[] rowDataKeys = Grid_V_TB_ASK.DataKeys[Grid_V_TB_ASK.SelectedRowIndex];
|
|
|
|
string AskBillNum = rowDataKeys[2] as string;
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(string.Format("../PlanData/SCP_ASK_DETAIL.aspx?AskBillNum={0}", AskBillNum)));
|
|
}
|
|
|
|
protected void btnAsn_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid_V_TB_ASK.SelectedRowIndexArray.Count() == 0)
|
|
{
|
|
PageContext.RegisterStartupScript(Alert.GetShowInTopReference("没有选择数据!"));
|
|
return;
|
|
|
|
}
|
|
object[] rowDataKeys = Grid_V_TB_ASK.DataKeys[Grid_V_TB_ASK.SelectedRowIndex];
|
|
|
|
string AskBillNum = rowDataKeys[2] as string;
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(string.Format("../PlanData/SCP_ASN_LIST.aspx?AskBillNum={0}", AskBillNum)) + Window1.GetMaximizeReference());
|
|
}
|
|
|
|
protected void BtnPublish_Click(object sender, EventArgs e)
|
|
{
|
|
int[] _selections = Grid_V_TB_ASK.SelectedRowIndexArray;
|
|
List<string> _AskList = new List<string>();
|
|
List<String[]> _AskLists = new List<String[]>();
|
|
for (int i = 0, count = Grid_V_TB_ASK.Rows.Count; i < count; i++)
|
|
{
|
|
if (_selections.Contains(i))
|
|
{
|
|
object[] rowDataKeys = Grid_V_TB_ASK.DataKeys[i];
|
|
if (!string.IsNullOrEmpty(rowDataKeys[2].ToString()))
|
|
{
|
|
_AskList.Add(rowDataKeys[2].ToString());
|
|
}
|
|
if (Convert.ToInt32(rowDataKeys[7]) == (int)AskState.New)
|
|
{
|
|
String[] arr = new String[] { rowDataKeys[2].ToString(), rowDataKeys[3].ToString() };
|
|
_AskLists.Add(arr);
|
|
}
|
|
}
|
|
}
|
|
var ret = SCP_ASK_CONTROLLER.Save_TB_ASK_STATE(_AskList, AskState.Release);
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
if (CurrentUser.ConfigList.ContainsKey("供应商邮件"))
|
|
{
|
|
if (CurrentUser.FactoryList != null && CurrentUser.FactoryList.Count > 0)
|
|
{
|
|
foreach (string[] _arr in _AskLists)
|
|
{
|
|
SCP.Common.MailManager.SendMail(_arr[1], string.Format("发布了新的要货看板编号{0}", _arr[0]), string.Format("新的要货单信息{0}", _arr[0]), CurrentUser.FactoryList.FirstOrDefault());
|
|
}
|
|
}
|
|
}
|
|
Alert.Show("批量发布成功!");
|
|
BindAsk();
|
|
}
|
|
else
|
|
{
|
|
Alert.Show(ret.Message);
|
|
}
|
|
}
|
|
|
|
protected void BtnCanclePublish_Click(object sender, EventArgs e)
|
|
{
|
|
int[] _selections = Grid_V_TB_ASK.SelectedRowIndexArray;
|
|
List<string> _AskList = new List<string>();
|
|
for (int i = 0, count = Grid_V_TB_ASK.Rows.Count; i < count; i++)
|
|
{
|
|
if (_selections.Contains(i))
|
|
{
|
|
object[] rowDataKeys = Grid_V_TB_ASK.DataKeys[i];
|
|
if (!string.IsNullOrEmpty(rowDataKeys[2].ToString()))
|
|
{
|
|
_AskList.Add(rowDataKeys[2].ToString());
|
|
}
|
|
}
|
|
}
|
|
var ret = SCP_ASK_CONTROLLER.Save_TB_ASK_STATE(_AskList, AskState.Confirm);
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
BindAsk();
|
|
}
|
|
else
|
|
{
|
|
Alert.Show(ret.Message);
|
|
}
|
|
}
|
|
protected void BtnStop_Click(object sender, EventArgs e)
|
|
{
|
|
int[] _selections = Grid_V_TB_ASK.SelectedRowIndexArray;
|
|
List<string> _AskList = new List<string>();
|
|
for (int i = 0, count = Grid_V_TB_ASK.Rows.Count; i < count; i++)
|
|
{
|
|
if (_selections.Contains(i))
|
|
{
|
|
object[] rowDataKeys = Grid_V_TB_ASK.DataKeys[i];
|
|
if (!string.IsNullOrEmpty(rowDataKeys[2].ToString()))
|
|
{
|
|
_AskList.Add(rowDataKeys[2].ToString());
|
|
}
|
|
}
|
|
}
|
|
var ret = SCP_ASK_CONTROLLER.Save_TB_ASK_STATE(_AskList, AskState.Complete);
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
if (ret.MessageList.Count > 0)
|
|
{
|
|
Alert.Show(string.Join("<br>", ret.MessageList));
|
|
}
|
|
else
|
|
{
|
|
Alert.Show("批量关闭完成成功!");
|
|
}
|
|
BindAsk();
|
|
}
|
|
else
|
|
{
|
|
Alert.Show(ret.Message);
|
|
}
|
|
}
|
|
protected void btnShow_Click(object sender, EventArgs e)
|
|
{
|
|
gp1.Hidden = false;
|
|
}
|
|
|
|
protected void BtnClose_Click(object sender, EventArgs e)
|
|
{
|
|
gp1.Hidden = true;
|
|
}
|
|
|
|
protected void BtnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
BindAsk();
|
|
}
|
|
|
|
|
|
protected void ddlGridPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid_V_TB_ASK.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue);
|
|
BindAsk();
|
|
}
|
|
|
|
protected void btnInput_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
string _fileName = FileUp.FileName;
|
|
if (string.IsNullOrEmpty(_fileName))
|
|
{
|
|
Alert.Show("选择文件为空!");
|
|
return;
|
|
}
|
|
string _lx = _fileName.Split('.')[1];
|
|
Stream _stream = FileUp.PostedFile.InputStream;
|
|
DataTable _dt = new DataTable();
|
|
if (_lx == "xls")
|
|
{
|
|
_dt= ExcelHelper.GetDataTable(_stream);
|
|
}
|
|
else
|
|
{
|
|
_dt=ExcelHelper.GetDataTableOfXlsx(_stream);
|
|
}
|
|
var datesetlist = ConvertHelper.ToList<SCP_PO_EXCEL>(ExcelHelper.RemoveEmpty(_dt)).ToList();
|
|
var list = datesetlist.Where(p => int.Parse(p.数量) != 0).ToList();
|
|
bool _isAutoPublish = false;
|
|
if(CurrentUser.ConfigList.ContainsKey("导入要货看板自动发布"))
|
|
{
|
|
_isAutoPublish = true;
|
|
}
|
|
var ret = SCP_PO_CONTROLLER.EXCEL_PO_TO_ASK(datesetlist, CurrentUser.Name, CurrentUser.ChineseName, DateTime.Now, BillModType.Non_Contract, CurrentUser.FactoryList[0], _isAutoPublish);
|
|
List<string> message_list = SCP_PO_CONTROLLER.EXCEL_ASK_Check(list);
|
|
if (ret.State == ReturnStatus.Succeed && ret.Result == true)
|
|
{
|
|
if (ret.MessageList.Count > 0)
|
|
{
|
|
message_list.AddRange(ret.MessageList);
|
|
}
|
|
if (message_list.Count > 0)
|
|
{
|
|
Alert.Show(string.Join("<br>", message_list));
|
|
}
|
|
else
|
|
{
|
|
Alert.Show("导入成功!");
|
|
}
|
|
BindAsk();
|
|
}
|
|
else
|
|
{
|
|
Alert.Show(string.Join("<br>", ret.MessageList));
|
|
}
|
|
|
|
}
|
|
|
|
protected void Grid_V_TB_ASK_RowDataBound(object sender, GridRowEventArgs e)
|
|
{
|
|
var itm = e.DataItem as V_TB_ASK;
|
|
if (itm.Flag == "1")//1未完成得
|
|
{
|
|
highlightRows.Text += e.RowIndex.ToString() + ",";
|
|
}
|
|
}
|
|
protected void btnCreateAsk_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference("../../PlanData/SCP_PO_ASK.aspx"));
|
|
|
|
}
|
|
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindAsk();
|
|
}
|
|
protected void BtnSearchDetail_Click (object sender , EventArgs e)
|
|
{
|
|
string AskBillNum = TXT_AskBillNo.Text;
|
|
string VendName = TXT_VendName.Text;
|
|
string State = DDL_State.SelectedValue;
|
|
string PartCode = TXT_PartCode.Text;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(string.Format("../PlanData/SCP_ASK_DETAIL_PARTCODE.aspx?AskBillNum={0}&&VendName={1}&&State={2}&&PartCode={3}", AskBillNum, VendName, State, PartCode)));
|
|
}
|
|
protected void LinkButton_Click(object sender, EventArgs e)
|
|
{
|
|
Alert.Show($"<a href=\'/uploadfiles/{"要货看板模板.xlsx"}\'>{"要货看板模板.xlsx"}</a>", "请点击文件名下载", MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
}
|