Пример #1
0
 public static Boolean CreateUnit(UnitMaster unit)
 {
     Boolean flag = false;
     if (!(IsExistingUnit(unit)))
     {
         using (TransactionScope scope = new TransactionScope())
         {
             using (var context = new SycousCon())
             {
                 try
                 {
                     context.UnitMasters.AddObject(unit);
                     context.SaveChanges();
                     scope.Complete();
                     context.AcceptAllChanges();
                     flag = true;
                 }
                 catch (Exception ex)
                 {
                     context.Dispose();
                     throw;
                 }
             }
         }
     }
     return flag;
 }
Пример #2
0
 public static UnitMaster EditUnit(Int32 unitId)
 {
     UnitMaster unit = new UnitMaster();
     using (var context = new SycousCon())
     {
         try
         {
             unit = context.UnitMasters.SingleOrDefault(s => s.ID == unitId);
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
     return unit;
 }
Пример #3
0
 public static bool IsExistingUnit(UnitMaster unit)
 {
     using (var context = new SycousCon())
     {
         try
         {
             UnitMaster objunit = context.UnitMasters.SingleOrDefault(p => p.UnitCode.ToUpper() == unit.UnitCode.ToUpper() && p.IsDeleted==0);
             if (objunit != null)
             { return true; }
             else
             {
                 return false;
             }
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
 }
Пример #4
0
        public bool CreateRecord(Object Unitobj)
        {
            Boolean flag = false;
            Unit unit = (Unit)Unitobj;
            try
            {
                UnitMaster _unit = new UnitMaster();

                if (unit.UnitCode != null)
                {
                    _unit.UnitCode = unit.UnitCode.Trim();
                }
                if (unit.UnitName != null)
                {
                    _unit.UnitName = unit.UnitName.Trim();
                }

                if (unit.Multiplier != null)
                {
                    _unit.Volume = Convert.ToDecimal(unit.Multiplier);
                }

                _unit.CreateBy = unit.CreateBy;
                _unit.CreateDate = DateTime.Now;

                if(_unit.UnitCode != null)
                {
                    flag = DAL.DALUnit.CreateUnit(_unit);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return flag;
        }
Пример #5
0
        public static Boolean UpdateUnit(UnitMaster unit)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                Boolean bol = false;
                using (var context = new SycousCon())
                {
                    try
                    {
                        var Update = context.UnitMasters.Where(c => c.ID == unit.ID);

                        foreach (UnitMaster p in Update)
                        {
                            if (unit.UnitCode != null)
                            {
                                p.UnitCode = unit.UnitCode;
                            }
                            if (unit.UnitName != null)
                            {
                                p.UnitName = unit.UnitName;
                            }
                            if (unit.Volume != null)
                            {
                                p.Volume = unit.Volume;
                            }

                            p.ModifyDate = DateTime.Now;
                            p.ModifyBy = unit.ModifyBy;
                        }//
                        context.SaveChanges();
                        context.AcceptAllChanges();
                        scope.Complete();
                        context.Dispose();
                        bol = true;
                    }
                    catch (Exception ex)
                    {
                        context.Dispose();
                        throw;
                    }

                }// using
                return bol;
            } //trans
        }
Пример #6
0
 /// <summary>
 /// Create a new UnitMaster object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static UnitMaster CreateUnitMaster(global::System.Int32 id, global::System.Int32 isDeleted)
 {
     UnitMaster unitMaster = new UnitMaster();
     unitMaster.ID = id;
     unitMaster.IsDeleted = isDeleted;
     return unitMaster;
 }
Пример #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UnitMasters EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUnitMasters(UnitMaster unitMaster)
 {
     base.AddObject("UnitMasters", unitMaster);
 }