Beispiel #1
0
 public static Boolean CreateSupply(Supplier supply)
 {
     Boolean flag = false;
     if (!(IsExistingSupply(supply)))
     {
         using (TransactionScope scope = new TransactionScope())
         {
             using (var context = new SycousCon())
             {
                 try
                 {
                     context.Suppliers.AddObject(supply);
                     context.SaveChanges();
                     scope.Complete();
                     context.AcceptAllChanges();
                     flag = true;
                 }
                 catch (Exception ex)
                 {
                     context.Dispose();
                     throw;
                 }
             }
         }
     }
     return flag;
 }
 public IHttpActionResult PostSupplier(Supplier supplier)
 {
     DAL.Supplier model = new DAL.Supplier();
     // model = db.Suppliers.Where(s => s.Id == supplier.Id).FirstOrDefault();
     model.Code                     = supplier.Code;
     model.ContactNumber            = supplier.ContactNumber;
     model.CorrespondanceAddress1   = supplier.CorrespondanceAddress1;
     model.CorrespondanceAddress2   = supplier.CorrespondanceAddress2;
     model.CorrespondanceAddress3   = supplier.CorrespondanceAddress3;
     model.CorrespondanceCity       = supplier.CorrespondanceCity;
     model.CorrespondanceCountry    = supplier.CorrespondanceCountry;
     model.CorrespondancePostalCode = supplier.CorrespondancePostalCode;
     model.FaxNumber                = supplier.FaxNumber;
     model.Id                  = supplier.Id;
     model.Limit               = supplier.Limit;
     model.LogId               = supplier.LogId;
     model.Name                = supplier.Name;
     model.PermanentAddress1   = supplier.PermanentAddress1;
     model.PermanentAddress2   = supplier.PermanentAddress2;
     model.PermanentAddress3   = supplier.PermanentAddress3;
     model.PermanentCity       = supplier.PermanentCity;
     model.PermanentCountry    = supplier.PermanentCountry;
     model.PermanentPostalCode = supplier.PermanentPostalCode;
     model.RegistrationDate    = supplier.RegistrationDate;
     model.CreatedOn           = System.DateTime.UtcNow;
     model.UpdatedOn           = System.DateTime.UtcNow;
     model.IsActive            = true;
     db.Suppliers.Add(model);
     db.SaveChanges();
     return(Ok(true));
 }
        public bool deleteSupplier(Supplier sDel)
        {
            try
            {
               Supplier s = getSupplier(sDel).First();
                ContextDB.Suppliers.DeleteObject(s);

                ContextDB.SaveChanges();

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
Beispiel #4
0
 public static Supplier EditSupply(Int64 SupplyId)
 {
     Supplier supply = new Supplier();
     using (var context = new SycousCon())
     {
         try
         {
             supply = context.Suppliers.SingleOrDefault(s => s.ID == SupplyId);
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
     return supply;
 }
Beispiel #5
0
 public static bool IsExistingSupply(Supplier supply)
 {
     using (var context = new SycousCon())
     {
         try
         {
             Supplier objsupply = context.Suppliers.SingleOrDefault(p => p.ClientID == supply.ClientID && p.IsDeleted == 0 && p.SiteID == supply.SiteID && p.EnergyID == supply.EnergyID && p.UnitID == supply.UnitID);
             if (objsupply != null)
             { return true; }
             else
             {
                 return false;
             }
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
 }
Beispiel #6
0
        public static Boolean UpdateSupply(Supplier supply)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                Boolean bol = false;
                using (var context = new SycousCon())
                {
                    try
                    {
                        var Update = context.Suppliers.Where(c => c.ID == supply.ID);

                        foreach (Supplier p in Update)
                        {
                            if (supply.ClientID != null)
                            {
                                p.ClientID = supply.ClientID;
                            }
                            if (supply.SiteID != null)
                            {
                                p.SiteID = supply.SiteID;
                            }
                            if (supply.EnergyID != null)
                            {
                                p.EnergyID = supply.EnergyID;
                            }
                            if (supply.UnitID != null)
                            {
                                p.UnitID = supply.UnitID;
                            }
                            if (supply.Volume != null)
                            {
                                p.Volume = supply.Volume;
                            }
                            else
                            { p.Volume = null; }
                            p.ModifyDate = DateTime.Now;
                            p.ModifyBy = supply.ModifyBy;
                        }//
                        context.SaveChanges();
                        context.AcceptAllChanges();
                        scope.Complete();
                        context.Dispose();
                        bol = true;
                    }
                    catch (Exception ex)
                    {
                        context.Dispose();
                        throw;
                    }

                }// using
                return bol;
            } //trans
        }
        public List<Supplier> getSupplier(Supplier supplierVal)
        {
            var sp = from s in ContextDB.Suppliers
                     where (s.Supplier_ID == supplierVal.Supplier_ID || supplierVal.Supplier_ID == null)
                     && (s.Supplier_Name == supplierVal.Supplier_Name || supplierVal.Supplier_Name == null)
                     && (s.Context_Name == supplierVal.Context_Name || supplierVal.Context_Name == null)
                     && (s.Phone_No == supplierVal.Phone_No || supplierVal.Phone_No == null)
                     && (s.Fax_No == supplierVal.Fax_No || supplierVal.Fax_No == null)
                     && (s.Address == supplierVal.Address || supplierVal.Address == null)
                     &&(s.Email==supplierVal.Email||supplierVal.Email==null)
                     select s;

            return sp.ToList<Supplier>();
        }
 public void createSupplier(Supplier s)
 {
     ContextDB.Suppliers.AddObject(s);
     ContextDB.SaveChanges();
 }
        //public Supplier getSupplier(Supplier supplierVal)
        //{
        //    var sp = from s in ContextDB.Suppliers
        //             where (s.Supplier_ID == supplierVal.Supplier_ID || supplierVal.Supplier_ID == null)
        //             && (s.Supplier_Name == supplierVal.Supplier_Name || supplierVal.Supplier_Name == null)
        //             && (s.Context_Name == supplierVal.Context_Name || supplierVal.Context_Name == null)
        //             && (s.Phone_No == supplierVal.Phone_No || supplierVal.Phone_No == null)
        //             && (s.Fax_No == supplierVal.Fax_No || supplierVal.Fax_No == null)
        //             && (s.Address == supplierVal.Address || supplierVal.Address == null)
        //             select s;
        //    return sp.First();
        //}
        public bool updateSupplierData(Supplier supplier)
        {
            Supplier sp = ContextDB.Suppliers.SingleOrDefault(p => p.Supplier_ID == supplier.Supplier_ID);
            sp.Supplier_ID = supplier.Supplier_ID;
            sp.Supplier_Name = supplier.Supplier_Name;
            sp.Phone_No = supplier.Phone_No;
            sp.Fax_No = supplier.Fax_No;
            sp.Address = supplier.Address;
            sp.Email = sp.Email;
            ContextDB.SaveChanges();

            return true;
        }
 public void Add(Supplier supplier)
 {
     context.Suppliers.Add(supplier);
     context.SaveChanges();
 }
Beispiel #11
0
        /// <summary>
        /// 新增信息
        /// </summary>
        /// <param name="supplier">模型</param>
        /// <returns>受影响行数</returns>
        public int InsSupplier(Supplier supplier)
        {
            string sql = @"INSERT INTO T_Supplier(Su_Name
                           , Su_Phone
                           , Su_Address
                           , Su_fax
                           , Su_Email
                           , Su_Bankaccounts
                           , Su_Bank
                           , Su_Profession
                           , Su_ProCode
                           , Su_Credit
                           , Su_Money
                           , Su_Surplus
                           , Su_Reckoning
                           , Su_Empname
                           , Su_EmpPhone
                           , Su_Remark
                           , Su_Enable
                           , Su_Clear
                           , Su_Code
                           , Su_Area) 
VALUES(@Su_Name
                           , @Su_Phone
                           , @Su_Address
                           , @Su_fax
                           , @Su_Email
                           , @Su_Bankaccounts
                           , @Su_Bank
                           , @Su_Profession
                           , @Su_ProCode
                           , @Su_Credit
                           , @Su_Money
                           , @Su_Surplus
                           , @Su_Reckoning
                           , @Su_Empname
                           , @Su_EmpPhone
                           , @Su_Remark
                           , @Su_Enable
                           , @Su_Clear
                           , @Su_Code
                           , @Su_Area)";

            SqlParameter[] sps =
            {
                new SqlParameter("@Su_Name",         XYEEncoding.strCodeHex(supplier.Su_Name)),
                new SqlParameter("@Su_Phone",        XYEEncoding.strCodeHex(supplier.Su_Phone)),
                new SqlParameter("@Su_Address",      XYEEncoding.strCodeHex(supplier.Su_Address)),
                new SqlParameter("@Su_fax",          XYEEncoding.strCodeHex(supplier.Su_fax)),
                new SqlParameter("@Su_Email",        XYEEncoding.strCodeHex(supplier.Su_Email)),
                new SqlParameter("@Su_Bankaccounts", XYEEncoding.strCodeHex(supplier.Su_Bankaccounts)),
                new SqlParameter("@Su_Bank",         XYEEncoding.strCodeHex(supplier.Su_Bank)),
                new SqlParameter("@Su_Profession",   XYEEncoding.strCodeHex(supplier.Su_Profession)),
                new SqlParameter("@Su_ProCode",      XYEEncoding.strCodeHex(supplier.Su_ProCode)),
                new SqlParameter("@Su_Credit",       XYEEncoding.strCodeHex(supplier.Su_Credit)),
                new SqlParameter("@Su_Money",        XYEEncoding.strCodeHex(supplier.Su_Money)),
                new SqlParameter("@Su_Surplus",      XYEEncoding.strCodeHex(supplier.Su_Surplus)),
                new SqlParameter("@Su_Reckoning",    XYEEncoding.strCodeHex(supplier.Su_Reckoning)),
                new SqlParameter("@Su_Empname",      XYEEncoding.strCodeHex(supplier.Su_Empname)),
                new SqlParameter("@Su_EmpPhone",     XYEEncoding.strCodeHex(supplier.Su_EmpPhone)),
                new SqlParameter("@Su_Remark",       XYEEncoding.strCodeHex(supplier.Su_Remark)),
                new SqlParameter("@Su_Enable",       supplier.Su_Enable),
                new SqlParameter("@Su_Clear",        supplier.Su_Clear),
                new SqlParameter("@Su_Code",         XYEEncoding.strCodeHex(supplier.Su_Code)),
                new SqlParameter("@Su_Area",         XYEEncoding.strCodeHex(supplier.Su_Area))
            };
            return(DbHelperSQL.ExecuteSql(sql, sps));
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Suppliers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSuppliers(Supplier supplier)
 {
     base.AddObject("Suppliers", supplier);
 }
 /// <summary>
 /// Create a new Supplier object.
 /// </summary>
 /// <param name="supplier_ID">Initial value of the Supplier_ID property.</param>
 public static Supplier CreateSupplier(global::System.String supplier_ID)
 {
     Supplier supplier = new Supplier();
     supplier.Supplier_ID = supplier_ID;
     return supplier;
 }
 /// <summary>
 /// Create a new Supplier object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static Supplier CreateSupplier(global::System.Int64 id, global::System.Int32 isDeleted)
 {
     Supplier supplier = new Supplier();
     supplier.ID = id;
     supplier.IsDeleted = isDeleted;
     return supplier;
 }
 public void Update(Supplier supplier)
 {
     context.Suppliers.Update(supplier);
     context.SaveChanges();
 }
        public Supplier getSupplierSingle(Supplier supplierVal)
        {
            var sp = from s in ContextDB.Suppliers
                     where (s.Supplier_ID == supplierVal.Supplier_ID || supplierVal.Supplier_ID == null)
                     && (s.Supplier_Name == supplierVal.Supplier_Name || supplierVal.Supplier_Name == null)
                     && (s.Context_Name == supplierVal.Context_Name || supplierVal.Context_Name == null)
                     && (s.Phone_No == supplierVal.Phone_No || supplierVal.Phone_No == null)
                     && (s.Fax_No == supplierVal.Fax_No || supplierVal.Fax_No == null)
                     && (s.Address == supplierVal.Address || supplierVal.Address == null)
                     select s;

            return sp.First();
        }
        public bool updateSupplier(Supplier supplierUpdate)
        {
            try
            {
                //Supplier s = getSupplierSingle(supplierUpdate);
                Supplier s = new Supplier();
                s.Supplier_ID = supplierUpdate.Supplier_ID;
                s.Supplier_Name = supplierUpdate.Supplier_Name;
                s.Context_Name = supplierUpdate.Context_Name;
                s.Phone_No = supplierUpdate.Phone_No;
                s.Fax_No = supplierUpdate.Fax_No;
                s.Address = supplierUpdate.Address;
                s.Email = supplierUpdate.Email;
                ContextDB.SaveChanges();

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
Beispiel #18
0
        public bool UpdateRecord(Object supplyobj)
        {
            Boolean flag = false;
            SupplyMaster supply = (SupplyMaster)supplyobj;
            try
            {
                Supplier _supply = new Supplier();

                if (supply.ClientID != null)
                {
                    _supply.ClientID = supply.ClientID;
                }
                if (supply.SiteID != null)
                {
                    _supply.SiteID = supply.SiteID;
                }
                if (supply.UnitID != null)
                {
                    _supply.UnitID = supply.UnitID;
                }
                if (supply.EnergyID != null)
                {
                    _supply.EnergyID = supply.EnergyID;
                }

                if (supply.ID != null)
                {
                    _supply.ID = Convert.ToInt64(supply.ID);
                }
                if (supply.Multiplier != null)
                {
                    _supply.Volume = Convert.ToDecimal(supply.Multiplier);
                }

                _supply.ModifyBy = supply.ModifyBy;
                _supply.ModifyDate = DateTime.Now;
                if (_supply.ID != null)
                {
                    flag = DAL.DALSupplier.UpdateSupply(_supply);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return flag;
        }
Beispiel #19
0
 public bool Save(Supplier obj)
 {
     return(database.ExecuteNonQuery("SaveSupplier", obj.Name, obj.Email, obj.Tel, obj.AttachmentId, obj.WardId, obj.Address, obj.TaxCode) > 0);
 }