diff --git a/Common/MyWebSmtpMail.cs b/Common/MyWebSmtpMail.cs index b04f877..2688946 100644 --- a/Common/MyWebSmtpMail.cs +++ b/Common/MyWebSmtpMail.cs @@ -87,6 +87,54 @@ namespace CK.SCP.Common } } } + + + public void SendOrdersEmail(string To, string Body, string Title) + { + mailMessage = new MailMessage(); + mailMessage.To.Add(To); + mailMessage.From = new System.Net.Mail.MailAddress(this.from); + mailMessage.Subject = Title; + mailMessage.Body = Body; + mailMessage.IsBodyHtml = true; + mailMessage.BodyEncoding = System.Text.Encoding.UTF8; + mailMessage.Priority = System.Net.Mail.MailPriority.Normal; + + if (mailMessage != null) + { + smtpClient = new SmtpClient(); + if (!credentials) + { + smtpClient.Credentials = new System.Net.NetworkCredential(username, password); + } + smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; + smtpClient.Host = server; + smtpClient.Port = port; + smtpClient.EnableSsl = enablessl; + //smtpClient.Send(mailMessage); + //smtpClient.SendAsync(mailMessage, null); + + //如果服务器支持安全连接,则将安全连接设为true + //smtpClient.EnableSsl = true; + try + { + //是否使用默认凭据,若为false,则使用自定义的证书,就是下面的networkCredential实例对象 + smtpClient.UseDefaultCredentials = false; + + //指定邮箱账号和密码,需要注意的是,这个密码是你在QQ邮箱设置里开启服务的时候给你的那个授权码 + System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(username, password); + smtpClient.Credentials = networkCredential; + + //发送邮件 + smtpClient.Send(mailMessage); + + } + catch (System.Net.Mail.SmtpException ex) + { + throw ex; + } + } + } } public class EmailAddress diff --git a/Controller/CK.SCP.Controller.csproj b/Controller/CK.SCP.Controller.csproj index 0b11d10..53152c9 100644 --- a/Controller/CK.SCP.Controller.csproj +++ b/Controller/CK.SCP.Controller.csproj @@ -80,6 +80,7 @@ + diff --git a/Controller/SCP_MPO_CONTROLLER.cs b/Controller/SCP_MPO_CONTROLLER.cs new file mode 100644 index 0000000..e4417df --- /dev/null +++ b/Controller/SCP_MPO_CONTROLLER.cs @@ -0,0 +1,577 @@ +using System; +using System.Collections.Generic; +using System.Data.Entity.Migrations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CK.SCP.Models; +using CK.SCP.Models.Enums; +using CK.SCP.Models.ScpEntity; +using CK.SCP.Models.ScpEntity.ExcelImportEntity; +using CK.SCP.Utils; +using System.Data.Entity.Core; +using CK.SCP.Models.ScpEntity.ExcelExportEnttity; +using System.Text.RegularExpressions; +using System.Threading; +using System.Data; +using Newtonsoft.Json; +using CK.SCP.Models.UniApiEntity; +using CK.SCP.Models.AppBoxEntity; + +namespace CK.SCP.Controller +{ + public class SCP_MPO_CONTROLLER + { + /// + /// 获取一般材料订单 + /// + /// + /// + public static void Get_V_TB_MPO_List(V_TB_MPO p_entity, Action>> p_action) + { + ResultObject> _ret = new ResultObject>(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + IQueryable q = db.V_TB_MPO; + if (p_entity.DocDateBegin != DateTime.MinValue) + { + q = q.Where(p => p.DocDate >= p_entity.DocDateBegin); + } + if (p_entity.DocDateEnd != DateTime.MinValue) + { + q = q.Where(p => p.DocDate <= p_entity.DocDateEnd); + } + if (!string.IsNullOrEmpty(p_entity.PurdocNO)) + { + q = q.Where(p => p.PurdocNO == p_entity.PurdocNO.Trim()); + } + if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0) + { + q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendorNO)); + } + _ret.State = ReturnStatus.Succeed; + _ret.Result = q; + p_action(_ret); + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 + { + var sb = new StringBuilder(); + + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_MPO_List", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_MPO_List", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_MPO_List", ex.ToString()); + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(e); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_MPO_List", e.Message); + throw e; + } + } + + /// + /// 获取一般材料订单明细 + /// + /// + /// + public static void Get_V_TB_MPO_DETAIL_List(V_TB_MPO_DETAIL p_entity, Action>> p_action) + { + ResultObject> _ret = new ResultObject>(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + IQueryable q = db.V_TB_MPO_DETAIL; + if (p_entity.purdocnolist != null && p_entity.purdocnolist.Count > 0) + { + q = q.Where(p => p_entity.purdocnolist.Contains(p.PurdocNO)); + } + _ret.State = ReturnStatus.Succeed; + _ret.Result = q; + p_action(_ret); + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 + { + var sb = new StringBuilder(); + + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_MPO_DETAIL_List", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_MPO_DETAIL_List", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_MPO_DETAIL_List", ex.ToString()); + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(e); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Get_V_TB_MPO_DETAIL_List", e.Message); + throw e; + } + } + + /// + /// 一般材料订单明细列表 + /// + /// PurdocNOlist + /// + public static List GetMPODetailList(List p_lst) + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + return db.V_TB_MPO_DETAIL.Where(p => p_lst.Contains(p.PurdocNO) && p.Ctype != "D").ToList(); + } + } + + + /// + /// 作废传接口 + /// + /// + /// + public static ResultObject Save_ts_uni_api(List ls) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + + { + List lineError = new List(); + List ErrorList = new List(); + + foreach (var po in ls) + { + var po1 = db.TB_MATERIALORDERS.FirstOrDefault(t => t.PurdocNO == po && t.Ctype != "D"); + po1.AcceptStatus = (int)GeneralMaterialOrderState.Finish; + db.TB_MATERIALORDERS.AddOrUpdate(po1); + var po2 = db.TB_MATERIALORDERS_DETAIL.Where(t => t.PurdocNO == po && t.Ctype != "D").ToList(); + foreach (var po3 in po2) + { + po3.AcceptStatus = (int)GeneralMaterialOrderState.Finish; + db.TB_MATERIALORDERS_DETAIL.AddOrUpdate(po3); + } + var lx = db.TS_UNI_API.Where(t => t.BillNum == po && t.Receiver == "I").ToList(); + foreach (var po4 in lx) + { + po4.State = 1; + po4.Receiver = "D"; + db.TS_UNI_API.AddOrUpdate(po4); + } + } + } + + if (_ret.MessageList.Count == 0) + { + int state = db.SaveChanges(); + if (state != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + } + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + } + + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 + { + var sb = new StringBuilder(); + + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Save_PO_TO_ASK", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Save_PO_TO_ASK", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Save_PO_TO_ASK", ex.ToString()); + + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + + + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "Save_PO_TO_ASK", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + throw e; + } + return _ret; + } + + + /// + /// 保存状态 + /// + /// + /// + /// + public static ResultObject Save_MPO_STATE(List p_list, GeneralMaterialOrderState p_state) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + + switch (p_state) + { + case GeneralMaterialOrderState.Finish: + var orblist = db.TB_MATERIALORDERS.Where(q => p_list.Contains(q.PurdocNO)).ToList(); + var ctylist = orblist.Select(q => q.Ctype).ToList(); + if (ctylist.Contains("D")) + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "存在已经作废的数据,请重新选择!"; + _ret.MessageList.Add(_ret.Message); + return _ret; + } + var acclist = orblist.Select(q => q.AcceptStatus).ToList(); + if (acclist.Contains((int)GeneralMaterialOrderState.Finish)) + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "存在已经确认的数据,请重新选择!"; + _ret.MessageList.Add(_ret.Message); + return _ret; + } + foreach (var item in p_list) + { + var tbMater = db.TB_MATERIALORDERS.FirstOrDefault(q => q.PurdocNO == item); + tbMater.AcceptStatus = (int)GeneralMaterialOrderState.Finish; + var tbMaterList = db.TB_MATERIALORDERS_DETAIL.Where(q => q.PurdocNO == item).ToList(); + tbMaterList.ForEach(q => + { + q.AcceptStatus = (int)GeneralMaterialOrderState.Finish; + }); + db.TB_MATERIALORDERS.AddOrUpdate(itm1 => itm1.UID, tbMater); + db.TB_MATERIALORDERS_DETAIL.AddOrUpdate(itm => itm.UID, tbMaterList.ToArray()); + } + break; + case GeneralMaterialOrderState.New: + var MAblist = db.TB_MATERIALORDERS.Where(q => p_list.Contains(q.PurdocNO)).ToList(); + var ctypelist = MAblist.Select(q => q.Ctype).ToList(); + if (ctypelist.Contains("D")) + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "存在已经作废的数据,请重新选择!"; + _ret.MessageList.Add(_ret.Message); + return _ret; + } + var acceplist = MAblist.Select(q => q.AcceptStatus).ToList(); + if (acceplist.Contains((int)GeneralMaterialOrderState.New)) + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "存在已经待确认的数据,请重新选择!"; + _ret.MessageList.Add(_ret.Message); + return _ret; + } + foreach (var item in p_list) + { + var tbMater = db.TB_MATERIALORDERS.FirstOrDefault(q => q.PurdocNO == item); + tbMater.AcceptStatus = (int)GeneralMaterialOrderState.New; + var tbMaterList = db.TB_MATERIALORDERS_DETAIL.Where(q => q.PurdocNO == item).ToList(); + tbMaterList.ForEach(q => + { + q.AcceptStatus = (int)GeneralMaterialOrderState.New; + q.UpdateTime = DateTime.Now.ToString(); + }); + db.TB_MATERIALORDERS.AddOrUpdate(itm1 => itm1.UID, tbMater); + db.TB_MATERIALORDERS_DETAIL.AddOrUpdate(itm => itm.UID, tbMaterList.ToArray()); + } + break; + } + if (db.SaveChanges() != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + return _ret; + + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "数据更新失败!"; + _ret.MessageList.Add(_ret.Message); + return _ret; + } + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 + { + var sb = new StringBuilder(); + + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MPO_CONTROLLER), "Save_MPO_STATE", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MPO_CONTROLLER), "Save_MPO_STATE", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MPO_CONTROLLER), "Save_MPO_STATE", ex.ToString()); + + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + + + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_MPO_CONTROLLER), "Save_MPO_STATE", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + } + return _ret; + } + + /// + /// 获取材料订单主表数据 + /// + /// + /// + public static TB_MATERIALORDERS GetTbMaterialorders(string PurdocNO) + { + TB_MATERIALORDERS MATERIALORDERS = new TB_MATERIALORDERS(); + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + MATERIALORDERS = db.TB_MATERIALORDERS.FirstOrDefault(q => q.PurdocNO == PurdocNO); + } + return MATERIALORDERS; + } + + + /// + /// 获取材料订单明细表数据 + /// + /// + /// + public static List GetTbMaterialordersDetailList(string PurdocNO) + { + List MATERIALORDERS = new List(); + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + MATERIALORDERS = db.TB_MATERIALORDERS_DETAIL.Where(q => q.PurdocNO == PurdocNO).ToList(); + } + return MATERIALORDERS; + } + + /// + /// 打印数据 + /// + /// + /// + public static DataSet MPO_REPORT(string PurdocNO) + { + DataSet ds = new DataSet(); + + TB_MATERIALORDERS order = GetTbMaterialorders(PurdocNO); + V_MPO_PRINT print = new V_MPO_PRINT(); + print.PURDOCNO = order.PurdocNO; + print.DOCDATE = order.DocDate.ToString("yyyy-MM-dd"); + print.PHONE = order.PHONE; + print.FAXNUM = order.FAXNUM; + print.PURGRPDESC = order.PurgrpDesc; + print.VendorNO = order.VendorNO; + print.FIRSTTELNO = order.FIRSTTELNO; + print.STAGEDESC = order.STAGEDESC; + + TA_VENDER vender = GET_TA_VENDER(order.VendorNO); + if (vender != null) + { + print.CAAIFax = vender.VendName; + print.CurrentUserAdress = vender.Address; + print.RESPONSIBLESALESPERSON = vender.Contacter; + print.SupplierFax = vender.Fax; + } + List detailList = GetTbMaterialordersDetailList(PurdocNO); + List lsDetail = new List(); + decimal SUM = 0.00M; + detailList.ForEach(p => + { + V_MPO_PRINT_DETAIL _detail = new V_MPO_PRINT_DETAIL(); + _detail.PURCHASEREQNO = p.PurchaseReqNO; + _detail.PROPOSERDESC = p.ProposerDesc; + _detail.MTLNO = p.MtlNO; + _detail.SHORTTEXT = p.Shorttext; + _detail.SIZECOL = p.SizeCol; + _detail.UNITDES = p.Unitdes; + _detail.QUANTITY = p.Quantity.ToString("#.####"); + _detail.PRICE = p.PRICE.ToString("#.######"); + _detail.NETVALUE = p.NetValue.ToString("#.######"); + _detail.PURINFORECORD = p.PurinfoReCord; + _detail.ITEMDELIVERYDATE = p.ItemDeliveryDate.ToString("yyyy-MM-dd"); + _detail.GLACCTNODES = p.Glaccnum; + _detail.COSTCENTERDES = p.CostCenterDes; + lsDetail.Add(_detail); + SUM += p.NetValue; + }); + print.Total = SUM.ToString("F6"); + var dt = ConvertHelper.ToDataTable(new List { print }); + ds.Tables.Add(dt); + var dt1 = ConvertHelper.ToDataTable(lsDetail); + ds.Tables.Add(dt1); + return ds; + } + + /// + /// 获取打印相关的供应商信息 + /// + /// + /// + public static TA_VENDER GET_TA_VENDER (string VENDID) + { + TA_VENDER _VENDER = new TA_VENDER(); + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + _VENDER = db.TA_VENDER.FirstOrDefault(q => q.VendId == VENDID); + } + return _VENDER; + } + } +} + diff --git a/Models/CK.SCP.Models.csproj b/Models/CK.SCP.Models.csproj index 80b78ed..8c4e597 100644 --- a/Models/CK.SCP.Models.csproj +++ b/Models/CK.SCP.Models.csproj @@ -360,6 +360,10 @@ + + + + @@ -410,6 +414,7 @@ + @@ -475,6 +480,7 @@ + diff --git a/Models/Enums/DataState.cs b/Models/Enums/DataState.cs index f3f2710..116398d 100644 --- a/Models/Enums/DataState.cs +++ b/Models/Enums/DataState.cs @@ -26,4 +26,11 @@ namespace CK.SCP.Models.Enums Process = 1, Finish = 2, } + + public enum GeneralMaterialOrderState + { + Cancel = -1, + New = 0, + Finish = 1, + } } \ No newline at end of file diff --git a/Models/ScpEntities.cs b/Models/ScpEntities.cs index e1a2e93..8fe6aab 100644 --- a/Models/ScpEntities.cs +++ b/Models/ScpEntities.cs @@ -169,6 +169,11 @@ namespace CK.SCP.Models public virtual DbSet V_TB_ASK_RECEIVE { get; set; } public virtual DbSet TB_ASK_RECEIVE { get; set; } public virtual DbSet TB_UNCOMPLETE_TEMPASK { get; set; } + public virtual DbSet TB_MATERIALORDERS { get; set; } + public virtual DbSet TB_MATERIALORDERS_DETAIL { get; set; } + public virtual DbSet V_TB_MPO { get; set; } + public virtual DbSet V_TB_MPO_DETAIL { get; set; } + public virtual DbSet TS_Email { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity() diff --git a/Models/ScpEntity/TB_MATERIALORDERS.cs b/Models/ScpEntity/TB_MATERIALORDERS.cs new file mode 100644 index 0000000..affa1d7 --- /dev/null +++ b/Models/ScpEntity/TB_MATERIALORDERS.cs @@ -0,0 +1,52 @@ +using System; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace CK.SCP.Models.ScpEntity +{ + + public partial class TB_MATERIALORDERS + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long UID { get; set; } + + [DisplayName("ɹƾ֤")] + public string PurdocNO { get; set; } + + [DisplayName("ɹƾ֤")] + public string BuyListStrdes { get; set; } + [DisplayName("ƾ֤ڣڣ")] + public DateTime DocDate { get; set; } + [DisplayName("Ӧ̴")] + public string VendorNO { get; set; } + + [DisplayName("Ӧ")] + public string VendorDesc { get; set; } + + [DisplayName("ɹջˣ")] + public string PurgrpDesc { get; set; } + [DisplayName("״̬ 4=ͨ")] + public string ApprovalStatus { get; set; } + [DisplayName("Ӧ״̬")] + public int AcceptStatus { get; set; } + [DisplayName("ճ")] + public DateTime ItemdeliveryDate { get; set; } + [DisplayName("")] + public string CreatedByDesc{ get; set; } + [DisplayName("")] + public string CreatedBy { get; set; } + [DisplayName("״̬")] + public string Ctype { get; set; } + + [DisplayName("Ӧ̵ϵ绰")] + public string FIRSTTELNO { get; set; } + [DisplayName("绰")] + public string PHONE { get; set; } + [DisplayName("鴫")] + public string FAXNUM { get; set; } + [DisplayName("")] + public string STAGEDESC { get; set; } + } +} diff --git a/Models/ScpEntity/TB_MATERIALORDERS_DETAIL.cs b/Models/ScpEntity/TB_MATERIALORDERS_DETAIL.cs new file mode 100644 index 0000000..c88faf4 --- /dev/null +++ b/Models/ScpEntity/TB_MATERIALORDERS_DETAIL.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace CK.SCP.Models.ScpEntity +{ + + public partial class TB_MATERIALORDERS_DETAIL + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long UID { get; set; } + + [DisplayName("ɹƾ֤")] + public string PurdocNO { get; set; } + + [DisplayName("뵥")] + public string PurchaseReqNO { get; set; } + [DisplayName("")] + public string ProposerDesc { get; set; } + [DisplayName("Ϻ")] + public string MtlNO { get; set; } + [DisplayName("״̬ 4=ͨ")] + public string ApprovalStatus { get; set; } + [DisplayName("Ӧ״̬")] + public int AcceptStatus { get; set; } + + [DisplayName("")] + public string Shorttext { get; set; } + + [DisplayName("ͺŹ")] + public string SizeCol { get; set; } + [DisplayName("ƺ")] + public string Matbrand { get; set; } + + [DisplayName("λ")] + public string Unitdes { get; set; } + [DisplayName("")] + public decimal Quantity { get; set; } + [DisplayName("۸")] + public decimal PRICE { get; set; } + [DisplayName("")] + public decimal NetValue { get; set; } + [DisplayName("ɹϢ")] + public string PurinfoReCord { get; set; } + [DisplayName("Ҫ󵽻")] + public DateTime ItemDeliveryDate { get; set; } + [DisplayName("Ŀ")] + public string Glaccnum { get; set; } + [DisplayName("״̬")] + public string Ctype { get; set; } + [DisplayName("ɱ")] + public string CostCenterDes { get; set; } + [DisplayName("洢ص")] + public string StoreLocation { get; set; } + [DisplayName("ʱ")] + public string UpdateTime { get; set; } + + } +} diff --git a/Models/ScpEntity/TS_Email.cs b/Models/ScpEntity/TS_Email.cs new file mode 100644 index 0000000..a0b746c --- /dev/null +++ b/Models/ScpEntity/TS_Email.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace CK.SCP.Models.ScpEntity +{ + public partial class TS_Email + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long UID { get; set; } + [DisplayName("͵")] + [StringLength(50)] + public string EmailToUser { get; set; } + [DisplayName("͵ĵַ")] + public string EmailAddress { get; set; } + [DisplayName("")] + public string EmailString { get; set; } + [DisplayName("״̬ 0 1ͳɹ 2ʧ")] + public int EmailSendState { get; set; } + [DisplayName("ʧԭ")] + public string EmailSendFailReason { get; set; } + + } +} diff --git a/Models/ScpEntity/V_MPO_PRINT.cs b/Models/ScpEntity/V_MPO_PRINT.cs new file mode 100644 index 0000000..0a16aaa --- /dev/null +++ b/Models/ScpEntity/V_MPO_PRINT.cs @@ -0,0 +1,38 @@ +namespace CK.SCP.Models.ScpEntity +{ + public class V_MPO_PRINT + { + public string PURDOCNO { get; set; } + public string DOCDATE { get; set; } + public string PHONE { get; set; } + public string FAXNUM { get; set; } + public string VendorNO { get; set; } + public string PURGRPDESC { get; set; } + public string CAAIFax { get; set; } + public string CurrentUserAdress { get; set; } + public string RESPONSIBLESALESPERSON { get; set; } + public string SupplierFax { get; set; } + public string FIRSTTELNO { get; set; } + public string STAGEDESC { get; set; } + public string Total { get; set; } + + } + + public class V_MPO_PRINT_DETAIL + { + public string PURCHASEREQNO { get; set; } + public string PROPOSERDESC { get; set; } + public string MTLNO { get; set; } + public string SHORTTEXT { get; set; } + public string SIZECOL { get; set; } + public string UNITDES { get; set; } + public string QUANTITY { get; set; } + public string PRICE { get; set; } + public string NETVALUE { get; set; } + public string PURINFORECORD { get; set; } + public string ITEMDELIVERYDATE { get; set; } + public string GLACCTNODES { get; set; } + public string COSTCENTERDES { get; set; } + } + +} diff --git a/Models/ScpEntity/V_TB_MPO.cs b/Models/ScpEntity/V_TB_MPO.cs new file mode 100644 index 0000000..f9bee20 --- /dev/null +++ b/Models/ScpEntity/V_TB_MPO.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + + +namespace CK.SCP.Models.ScpEntity +{ + public partial class V_TB_MPO + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long UID { get; set; } + + [DisplayName("")] + public string PurdocNO { get; set; } + + [DisplayName("ɹƾ֤")] + public string BuyListStrdes { get; set; } + [DisplayName("ƾ֤ڣڣ")] + public DateTime DocDate { get; set; } + [DisplayName("Ӧ̴")] + public string VendorNO { get; set; } + + [DisplayName("Ӧ")] + public string VendorDesc { get; set; } + + [DisplayName("ɹջˣ")] + public string PurgrpDesc { get; set; } + public string ApprovalStatus { get; set; } + [DisplayName("ǰȷ״̬")] + public int AcceptStatus { get; set; } + [DisplayName("OA״̬")] + public string OASTATUS { get; set; } + + [DisplayName("ճ")] + public DateTime ItemdeliveryDate { get; set; } + [DisplayName("")] + public string CreatedByDesc { get; set; } + [DisplayName("")] + public string CreatedBy { get; set; } + [DisplayName("˵绰")] + public string CreatedByPhone { get; set; } + [DisplayName("״̬")] + public string Ctype { get; set; } + [DisplayName("Ӧ̵ϵ绰")] + public string FIRSTTELNO { get; set; } + [DisplayName("ǰ״̬")] + public string State_DESC { get; set; } + [DisplayName("")] + public string CType_DESC { get; set; } + [NotMapped] + public DateTime DocDateBegin { get; set; } + [NotMapped] + public DateTime DocDateEnd { get; set; } + [NotMapped] + public List UserInVendIds { get; set; } + } + +} diff --git a/Models/ScpEntity/V_TB_MPO_DETAIL.cs b/Models/ScpEntity/V_TB_MPO_DETAIL.cs new file mode 100644 index 0000000..0aad3b3 --- /dev/null +++ b/Models/ScpEntity/V_TB_MPO_DETAIL.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace CK.SCP.Models.ScpEntity +{ + + public partial class V_TB_MPO_DETAIL + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long UID { get; set; } + + [DisplayName("")] + public string PurdocNO { get; set; } + + [DisplayName("뵥")] + public string PurchaseReqNO { get; set; } + [DisplayName("")] + public string ProposerDesc { get; set; } + [DisplayName("Ϻ")] + public string MtlNO { get; set; } + public string ApprovalStatus { get; set; } + [DisplayName("ǰȷ״̬")] + public int AcceptStatus { get; set; } + [DisplayName("OA״̬")] + public string OASTATUS { get; set; } + [DisplayName("")] + public string Shorttext { get; set; } + + [DisplayName("ͺŹ")] + public string SizeCol { get; set; } + [DisplayName("ƺ")] + public string Matbrand { get; set; } + + [DisplayName("λ")] + public string Unitdes { get; set; } + [DisplayName("")] + public decimal Quantity { get; set; } + [DisplayName("۸")] + public decimal PRICE { get; set; } + [DisplayName("")] + public decimal NetValue { get; set; } + [DisplayName("ɹϢ")] + public string PurinfoReCord { get; set; } + [DisplayName("Ҫ󵽻")] + public DateTime ItemDeliveryDate { get; set; } + [DisplayName("Ŀ")] + public string Glaccnum { get; set; } + [DisplayName("״̬")] + public string Ctype { get; set; } + [DisplayName("ɱ")] + public string CostCenterDes { get; set; } + [DisplayName("洢ص")] + public string StoreLocation { get; set; } + public string State_DESC { get; set; } + public string CType_DESC { get; set; } + [NotMapped] + public List purdocnolist { get; set; } + + } +} diff --git a/SCP/Common/ReportHelper.cs b/SCP/Common/ReportHelper.cs index fd39a6c..a185f11 100644 --- a/SCP/Common/ReportHelper.cs +++ b/SCP/Common/ReportHelper.cs @@ -25,6 +25,7 @@ namespace SCP.Common ASN_PALLET =107, PALLET=105, SmallBARCODE = 106, + PO_MATERIAL = 131, } public class TextProvider { @@ -72,6 +73,9 @@ namespace SCP.Common case (int)PrintType.SmallBARCODE: ds = GET_TS_BAR_Small(p_request); break; + case (int)PrintType.PO_MATERIAL: + ds = GET_PO_MATERIAL(p_request); + break; } return ds; } @@ -290,6 +294,22 @@ namespace SCP.Common } return ds; } + + /// + /// 获取材料订单打印 + /// + /// + /// + private static DataSet GET_PO_MATERIAL(HttpRequest p_request) + { + DataSet ds = new DataSet(); + if (!string.IsNullOrEmpty(p_request["PurdocNO"])) + { + var PurdocNO = p_request["PurdocNO"].ToString(); + ds = SCP_MPO_CONTROLLER.MPO_REPORT(PurdocNO); + } + return ds; + } private static DataSet GET_CUSTOM_PAGE(HttpRequest p_request) { DataSet ds = new DataSet(); diff --git a/SCP/SCP.csproj b/SCP/SCP.csproj index 39159b6..e9cbc57 100644 --- a/SCP/SCP.csproj +++ b/SCP/SCP.csproj @@ -67,6 +67,9 @@ ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + + ..\packages\MailKit.3.1.0\lib\net452\MailKit.dll + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll @@ -92,6 +95,7 @@ + @@ -4572,6 +4576,8 @@ + + @@ -6034,6 +6040,20 @@ SCP_MAXPO_INCOMPLETE_DETAIL.aspx + + SCP_MPO_DETAIL.aspx + ASPXCodeBehind + + + SCP_MPO_DETAIL.aspx + + + SCP_PO_MATERIAL.aspx + ASPXCodeBehind + + + SCP_PO_MATERIAL.aspx + SCP_PO.aspx ASPXCodeBehind diff --git a/SCP/Views/富维冲压件/SCP_MPO_DETAIL.aspx b/SCP/Views/富维冲压件/SCP_MPO_DETAIL.aspx new file mode 100644 index 0000000..59065b6 --- /dev/null +++ b/SCP/Views/富维冲压件/SCP_MPO_DETAIL.aspx @@ -0,0 +1,75 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SCP_MPO_DETAIL.aspx.cs" Inherits="SCP.Views.富维冲压件.SCP_MPO_DETAIL" %> + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SCP/Views/富维冲压件/SCP_MPO_DETAIL.aspx.cs b/SCP/Views/富维冲压件/SCP_MPO_DETAIL.aspx.cs new file mode 100644 index 0000000..828a80f --- /dev/null +++ b/SCP/Views/富维冲压件/SCP_MPO_DETAIL.aspx.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web.UI.WebControls; +using CK.SCP.Models.ScpEntity; +using CK.SCP.Controller; +using FineUI; +using CK.SCP.Models.Enums; + +namespace SCP.Views.富维冲压件 +{ + public partial class SCP_MPO_DETAIL : PageBase + { + + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + if (!string.IsNullOrEmpty(Request["PurdocNO"])) + { + BindDetail(); + } + else + { + Alert.Show("请选择数据后再查看明细!"); + return; + } + } + } + + public void SearchV_TB_PO_DETAIL(Action> p_action) + { + V_TB_MPO_DETAIL _entity = new V_TB_MPO_DETAIL(); + string purdocnolist =Request["PurdocNO"]; + _entity.purdocnolist = purdocnolist.Split(',').ToList(); + SCP_MPO_CONTROLLER.Get_V_TB_MPO_DETAIL_List(_entity,(_ret)=> { + if (_ret.State == ReturnStatus.Succeed) + { + p_action(_ret.Result); + } + }); + } + + + public void BindDetail() + { + if (CurrentUser.RoleList.Contains("供应商")) + { + //确认订单 + btnAccept.Hidden = false; + btnCancel.Hidden = false; + } + SearchV_TB_PO_DETAIL((ret)=>{ + this.Grid_V_TB_MPO_DETAIL.RecordCount = ret.Count(); + var list = SortAndPage(ret, Grid_V_TB_MPO_DETAIL); + Grid_V_TB_MPO_DETAIL.DataSource = list.ToList(); + Grid_V_TB_MPO_DETAIL.DataBind(); + }); + } + + protected void Grid_V_TB_PO_DETAIL_PageIndexChange(object sender, GridPageEventArgs e) + { + BindDetail(); + } + protected void ddlGridPageSize_SelectedIndexChanged(object sender, EventArgs e) + { + Grid_V_TB_MPO_DETAIL.PageSize = Convert.ToInt32(ddlGridPageSize.SelectedValue); + + BindDetail(); + } + /// + /// 审批通过 + /// + /// + /// + protected void btnAccept_Click(object sender, EventArgs e) + { + int[] selections = Grid_V_TB_MPO_DETAIL.SelectedRowIndexArray; + List NOList = new List(); + List ctylist = new List(); + List AcceptStatusList = new List(); + if (selections.Count() ==0 ) + { + Alert.Show("您未选择数据进行审批"); + return; + } + else + { + foreach (int rowIndex in selections) + { + NOList.Add(Grid_V_TB_MPO_DETAIL.DataKeys[rowIndex][1] as string); + ctylist.Add(Grid_V_TB_MPO_DETAIL.DataKeys[rowIndex][4] as string); + var app = Grid_V_TB_MPO_DETAIL.DataKeys[rowIndex][3].ToString(); + AcceptStatusList.Add(int.Parse(app)); + } + NOList = NOList.Distinct().ToList(); + if (ctylist.Contains("D")) + { + Alert.Show("选择的数据包含已经作废的数据"); + return; + } + if (AcceptStatusList.Contains((int)GeneralMaterialOrderState.Finish)) + { + Alert.Show("选择的数据包含已确认的数据"); + return; + } + + var ret = SCP_MPO_CONTROLLER.Save_MPO_STATE(NOList, GeneralMaterialOrderState.Finish); + + if (ret.State == ReturnStatus.Succeed) + { + Alert.Show("确认成功"); + BindDetail(); + } + else + { + Alert.Show(string.Join("
", ret.MessageList)); + return; + } + } + + + } + /// + /// 取消审批 + /// + /// + /// + protected void btnCancel_Click(object sender, EventArgs e) + { + int[] selections = Grid_V_TB_MPO_DETAIL.SelectedRowIndexArray; + List NOList = new List(); + List ctylist = new List(); + List AcceptStatusList = new List(); + if (selections.Count() == 0) + { + Alert.Show("您未选择数据进行取消审批"); + return; + } + else + { + foreach (int rowIndex in selections) + { + NOList.Add(Grid_V_TB_MPO_DETAIL.DataKeys[rowIndex][1] as string); + ctylist.Add(Grid_V_TB_MPO_DETAIL.DataKeys[rowIndex][4] as string); + AcceptStatusList.Add(int.Parse(Grid_V_TB_MPO_DETAIL.DataKeys[rowIndex][3].ToString())); + } + NOList = NOList.Distinct().ToList(); + if (ctylist.Contains("D")) + { + Alert.Show("选择的数据包含已经作废的数据"); + return; + } + if (AcceptStatusList.Contains((int)GeneralMaterialOrderState.New)) + { + Alert.Show("选择的数据包含新建的数据"); + return; + } + var ret = SCP_MPO_CONTROLLER.Save_MPO_STATE(NOList, GeneralMaterialOrderState.New); + + if (ret.State == ReturnStatus.Succeed) + { + Alert.Show("取消成功"); + BindDetail(); + } + else + { + Alert.Show(string.Join("
", ret.MessageList)); + return; + } + } + } + + } +} \ No newline at end of file diff --git a/SCP/Views/富维冲压件/SCP_MPO_DETAIL.aspx.designer.cs b/SCP/Views/富维冲压件/SCP_MPO_DETAIL.aspx.designer.cs new file mode 100644 index 0000000..2772da3 --- /dev/null +++ b/SCP/Views/富维冲压件/SCP_MPO_DETAIL.aspx.designer.cs @@ -0,0 +1,116 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace SCP.Views.富维冲压件 +{ + + + public partial class SCP_MPO_DETAIL + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// Panel1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.Panel Panel1; + + /// + /// Toolbar2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.Toolbar Toolbar2; + + /// + /// BTN_REFRESH 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.Button BTN_REFRESH; + + /// + /// btnAccept 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.Button btnAccept; + + /// + /// btnCancel 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.Button btnCancel; + + /// + /// HF_GRID_INDEX 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.HiddenField HF_GRID_INDEX; + + /// + /// Grid_V_TB_MPO_DETAIL 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.Grid Grid_V_TB_MPO_DETAIL; + + /// + /// ToolbarSeparator1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.ToolbarSeparator ToolbarSeparator1; + + /// + /// ToolbarText1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.ToolbarText ToolbarText1; + + /// + /// ddlGridPageSize 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.DropDownList ddlGridPageSize; + } +} diff --git a/SCP/Views/富维冲压件/SCP_PO_MATERIAL.aspx b/SCP/Views/富维冲压件/SCP_PO_MATERIAL.aspx new file mode 100644 index 0000000..f54788d --- /dev/null +++ b/SCP/Views/富维冲压件/SCP_PO_MATERIAL.aspx @@ -0,0 +1,119 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SCP_PO_MATERIAL.aspx.cs" Inherits="SCP.Views.富维冲压件.SCP_PO_MATERIAL" %> + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +