public int InsertLabel(List <t_labels> lists)
        {
            int result = 0;

            using (var scope = new TransactionScope(TransactionScopeOption.Required))
            {
                using (ERP2008Entities erp2008 = new ERP2008Entities())
                {
                    try
                    {
                        foreach (t_labels labels in lists)
                        {
                            erp2008.t_labels.Add(labels);
                            if (erp2008.SaveChanges() <= 0)
                            {
                                throw new Exception();
                            }
                        }
                        scope.Complete();
                        result = 1;
                    }
                    catch (Exception)
                    {
                        scope.Dispose();
                        result = 0;
                    }
                }
            }
            return(result);
        }
 public t_StAndClient_compaTable FindAndClientCompaTableByObject(t_StAndClient_compaTable compaTable)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         t_StAndClient_compaTable tStAndClientCompaTable = null;
         if (compaTable != null)
         {
             if (compaTable.Client_PN != null && compaTable.Client_cCusCode != null & compaTable.St_Type != null)
             {
                 try
                 {
                     tStAndClientCompaTable = (from i in erp2008.t_StAndClient_compaTable where i.Client_PN == compaTable.Client_PN && i.Client_cCusCode == compaTable.Client_cCusCode && i.St_Type == compaTable.St_Type select i
                                               ).SingleOrDefault();
                     return(tStAndClientCompaTable);
                 }
                 catch (Exception)
                 {
                     return(tStAndClientCompaTable);
                 }
             }
             //if (compaTable.Client_PN != null)
             //{
             //    tStAndClientCompaTable = (from i in erp2008.t_StAndClient_compaTable where i.Client_PN == compaTable.Client_PN select i
             //        ).SingleOrDefault();
             //}
         }
         return(tStAndClientCompaTable);
     }
 }
 public int InsertLabel(Entity.t_labels label)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         erp2008.t_labels.Add(label);
         return(erp2008.SaveChanges());
     }
 }
 public List <t_labels> FindLabelsesByCode(string code)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         return((from tabel in erp2008.t_labels where tabel.code == code select tabel
                 ).ToList());
     }
 }
Beispiel #5
0
 public List <SO_SODetails> FindSoDetailsByCsoAndCinvstd(string cSoCode, string cinvstd)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         List <SO_SODetails> details = null;
         details = (from detail in erp2008.SO_SODetails where detail.cSOCode == cSoCode && detail.cInvCode == cinvstd select detail
                    ).ToList();
         return(details);
     }
 }
Beispiel #6
0
 public List <SO_SODetails> FindSoDetailsByDetailses(SO_SODetails soDetails)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         List <SO_SODetails> details = null;
         details = (from detail in erp2008.SO_SODetails select detail
                    ).ToList();
         return(details);
     }
 }
 public long ExecPrSaveSerialNumber(System.Data.SqlClient.SqlParameter[] parameters)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         SqlParameter parameter = new SqlParameter("@oldNumber", SqlDbType.BigInt);
         parameter.Direction = ParameterDirection.Output;
         erp2008.Database.ExecuteSqlCommand("EXEC Pr_SaveSerialNumber @clientCode,@number,@oldNumber output", parameters[0], parameters[1], parameter);
         return((long)parameter.Value);
     }
 }
Beispiel #8
0
 public Entity.SA_Packs FindSaPacksBySaPacks(Entity.SA_Packs saPacks)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         SA_Packs saPack = null;
         saPack = (from pack in erp2008.SA_Packs where pack.cPCode == saPacks.cPCode select pack
                   ).SingleOrDefault();
         return(saPack);
     }
 }
Beispiel #9
0
 public Entity.SA_Packs FinSaPacksBysaCode(string saCode)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         SA_Packs saPacks = null;
         saPacks = (from saPack in erp2008.SA_Packs where saPack.cPCode == saCode select saPack
                    ).SingleOrDefault();
         return(saPacks);
     }
 }
 public Entity.SO_SOMain FindSoMainByCsoCode(string csoCode)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         SO_SOMain soMain = null;
         soMain =
             (from main in erp2008.SO_SOMain where main.cSOCode == csoCode select main).SingleOrDefault();
         return(soMain);
     }
 }
Beispiel #11
0
 public SO_SODetails FindSoDetailsById(int id)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         SO_SODetails details = null;
         details = (from de in erp2008.SO_SODetails
                    where de.AutoID == id
                    select de).SingleOrDefault();
         return(details);
     }
 }
Beispiel #12
0
 public DateTime GetServerDateTime()
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         var now = erp2008.Database.SqlQuery <DateTime?>("SELECT GetDate()").First();
         if (now == null)
         {
             now = new DateTime(1900, 1, 1, 0, 0, 0);
         }
         return(now.Value);
     }
 }
Beispiel #13
0
 public t_opencardpack FindOpencardpackByCode(string code)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         t_opencardpack card = new t_opencardpack();
         card =
             (from opencard in erp2008.t_opencardpack
              where opencard.Fbarcode == code
              select opencard).SingleOrDefault();
         return(card);
     }
 }
Beispiel #14
0
 public Entity.SO_SODetails FindSoDetailsBySoDetails(Entity.SO_SODetails soDetails)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         //有时候客户一个订单下单分几次下一个型号,此处用来提出明细单的说明    18-6-23 lee
         //一般一个订单号多个型号说明应该是一样的,所以直接拿第一个的说明就好了  18-6-23  lee
         SO_SODetails details = null;
         details = (from de in erp2008.SO_SODetails
                    where de.cSOCode == soDetails.cSOCode && de.cInvCode == soDetails.cInvCode
                    select de).ToList()[0];
         return(details);
     }
 }
Beispiel #15
0
 public Entity.t_opencardpack FindOpencardpackByCode(Entity.t_opencardpack opencardpack)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         t_opencardpack card = new t_opencardpack();
         card =
             (from opencard in erp2008.t_opencardpack
              //join b in erp2008.b_Inventory on opencard.FProductNo equals b.cInvCode
              //join sod in erp2008.SO_SODetails on opencard.cSOCode equals sod.cSOCode
              //join som in erp2008.SO_SOMain on opencard.cSOCode equals  som.cSOCode
              where opencard.Fbarcode == opencardpack.Fbarcode
              select opencard).SingleOrDefault();
         return(card);
     }
 }
Beispiel #16
0
 public Label_template FindLabelTemplatesById(int id)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         Label_template labelTemplates = null;
         if (id != 0)
         {
             labelTemplates =
                 (from labelTemplate in erp2008.Label_template
                  where labelTemplate.Label_NO == id
                  select labelTemplate
                 ).SingleOrDefault();
         }
         return(labelTemplates);
     }
 }
Beispiel #17
0
 public double FindSoDetailsQtyByCsoAndCinvstd(string cSoCode, string cinvstd)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         double sum   = 0.0;
         var    query = (from detail in erp2008.SO_SODetails
                         where detail.cSOCode == cSoCode && detail.cInvCode == cinvstd
                         select detail.iQuantity
                         ).Sum();
         if (query != null)
         {
             sum = (double)query;
         }
         return(sum);
     }
 }
Beispiel #18
0
 public b_User LongIn(b_User user)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         CustomMD5 custom = new CustomMD5();
         string    pwd    = custom.getpwd(user.cPassword);
         b_User    query  = (from u in erp2008.b_User where u.cUser_Id == user.cUser_Id && u.cPassword == pwd select u).SingleOrDefault();
         if (query != null)
         {
             return(query);
         }
         else
         {
             return(null);
         }
     }
 }
        public List <t_labels> FindLabelsesByOrderCodeTypeCode(string orderCode, string typeCode)
        {
            using (ERP2008Entities erp2008 = new ERP2008Entities())
            {
                List <t_labels> labels = null;
                try
                {
                    labels = (from l in erp2008.t_labels where l.orderCode == orderCode && l.typeCode == typeCode select l
                              ).ToList();
                }
                catch (Exception)
                {
                    labels = null;
                }

                return(labels);
            }
        }
Beispiel #20
0
 public List <Entity.Label_template> FindLabelTemplatesByClientCode(string clientCode)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         List <Label_template> labelTemplates = null;
         if (string.IsNullOrEmpty(clientCode))
         {
             labelTemplates = (from labelTemplate in erp2008.Label_template where labelTemplate.cCusCode == "STANDARD" select labelTemplate
                               ).ToList();
         }
         //labelTemplates = (from labelTemplate in erp2008.Label_template  where labelTemplate.cCusCode==clientCode || labelTemplate.cCusCode=="Semtech"   select labelTemplate
         //    ).ToList();
         string[] clientCodes = new string[] { clientCode, "STANDARD" };
         labelTemplates = (from labelTemplate in erp2008.Label_template where clientCodes.Contains(labelTemplate.cCusCode) select labelTemplate
                           ).ToList();
         //labelTemplates = (from labelTemplate in erp2008.Label_template where labelTemplate.cCusCode == clientCode || labelTemplate.cCusCode == "STANDARD" select labelTemplate
         //    ).ToList();
         return(labelTemplates);
     }
 }
 public int FindOrderSumQty(string orderCode, string typeCode)
 {
     using (ERP2008Entities erp2008 = new ERP2008Entities())
     {
         int sum = 0;
         try
         {
             var query =
                 (from labels in erp2008.t_labels
                  where labels.orderCode == orderCode && labels.typeCode == typeCode
                  select labels.qty
                 ).Sum();
             if (query != null)
             {
                 sum = (int)query;
             }
         }
         catch (Exception)
         {
             sum = 0;
         }
         return(sum);
     }
 }