コード例 #1
0
ファイル: BALEnergy.cs プロジェクト: arnabknd4/scs0400915
 public bool CreateRecord(Object energyobj)
 {
     Boolean flag = false;
     EnergyMaster energy = (EnergyMaster)energyobj;
     try
     {
         Energy _energy = new Energy();
         if (energy.EnergyName != null)
         {
             _energy.EnergyName = energy.EnergyName.Trim();
         }
         if (energy.EnergyCode != null)
         {
             _energy.EnergyCode = energy.EnergyCode.Trim().ToUpper();
         }
         _energy.CreateBy = energy.CreateBy;
         _energy.CreateDate = DateTime.Now;
         if (_energy.EnergyName != null)
         {
             flag = DAL.DALEnergy.CreateEnergy(_energy);
         }
     }
     catch (Exception ex)
     {
         throw;
     }
     return flag;
 }
コード例 #2
0
ファイル: DALEnergy.cs プロジェクト: arnabknd4/scs0400915
        public static Boolean CreateEnergy(Energy energy)
        {
            Boolean flag = false;
              if (!(IsExistingEnergy(energy)))
              {
              using (TransactionScope scope = new TransactionScope())
              {
                  using (var context = new SycousCon())
                  {
                      try
                      {
                          context.Energies.AddObject(energy);
                          context.SaveChanges();
                          scope.Complete();
                          context.AcceptAllChanges();
                          flag = true;
                      }
                      catch (Exception ex)
                      {
                          context.Dispose();
                          throw;
                      }
                  }//
              }// using
              }//if

              return flag;
        }
コード例 #3
0
ファイル: DALEnergy.cs プロジェクト: arnabknd4/scs0400915
 public static Energy EditEnergy(Int32 energyID)
 {
     Energy energy = new Energy();
       using (var context = new SycousCon())
       {
       try
       {
           energy = context.Energies.SingleOrDefault(s => s.ID == energyID);
       }
       catch (Exception ex)
       {
           context.Dispose();
           throw;
       }
       }
       return energy;
 }
コード例 #4
0
ファイル: DALEnergy.cs プロジェクト: arnabknd4/scs0400915
 public static Energy ViewEnergyRecord(Int32 energyID)
 {
     Energy objenergy = new Energy();
       using (var context = new SycousCon())
       {
       try
       {
           // Int32 CurrenctID = Int32.Parse(currencyID);
           objenergy = context.Energies.SingleOrDefault(p => p.ID == energyID);
           if (objenergy != null)
           { return objenergy; }
           else
           {
               objenergy = null;
               return objenergy;
           }
       }
       catch (Exception ex)
       {
           context.Dispose();
           throw;
       }
       }
 }
コード例 #5
0
ファイル: DALEnergy.cs プロジェクト: arnabknd4/scs0400915
        public static Boolean UpdateEnergy(Energy energy)
        {
            using (TransactionScope scope = new TransactionScope())
              {
              Boolean bol = false;
              using (var context = new SycousCon())
              {
                  try
                  {
                      var Update = context.Energies.Where(c => c.ID == energy.ID);

                      foreach (Energy p in Update)
                      {
                          if (energy.EnergyName != null)
                          {
                              p.EnergyName = energy.EnergyName.Trim();
                          }

                          if (energy.EnergyCode != null)
                          {
                              p.EnergyCode = energy.EnergyCode;
                          }
                          p.ModifyBy = energy.ModifyBy;
                          p.ModifyDate = DateTime.Now;

                      }//
                      context.SaveChanges();
                      context.AcceptAllChanges();
                      scope.Complete();
                      context.Dispose();
                      bol = true;
                  }
                  catch (Exception ex)
                  {
                      context.Dispose();
                      throw;
                  }

              }// using
              return bol;
              } //trans
        }
コード例 #6
0
ファイル: DALEnergy.cs プロジェクト: arnabknd4/scs0400915
 public static bool IsExistingEnergy(Energy energy)
 {
     using (var context = new SycousCon())
       {
       try
       {
           Energy objenergy = context.Energies.SingleOrDefault(p => p.EnergyName.ToUpper() == energy.EnergyName.ToUpper());
           if (objenergy != null)
           { return true; }
           else
           {
               return false;
           }
       }
       catch (Exception ex)
       {
           context.Dispose();
           throw;
       }
       }
 }
コード例 #7
0
ファイル: BALEnergy.cs プロジェクト: arnabknd4/scs0400915
        public bool UpdateRecord(Object energyobj)
        {
            Boolean flag = false;
            EnergyMaster energy = (EnergyMaster)energyobj;
            try
            {
                Energy _energy = new Energy();
                _energy.ID = Convert.ToInt32(energy.ID);
                if (energy.EnergyName != null)
                {
                    _energy.EnergyName = energy.EnergyName.Trim();
                }
                if (energy.EnergyCode != null)
                {
                    _energy.EnergyCode = energy.EnergyCode.Trim().ToUpper();
                }

                _energy.ModifyBy = energy.modifyBy;
                _energy.ModifyDate = DateTime.Now;
                if (_energy.ID!= null)
                {
                    flag = DAL.DALEnergy.UpdateEnergy(_energy);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return flag;
        }
コード例 #8
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Energies EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEnergies(Energy energy)
 {
     base.AddObject("Energies", energy);
 }
コード例 #9
0
 /// <summary>
 /// Create a new Energy object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static Energy CreateEnergy(global::System.Int32 id, global::System.Int32 isDeleted)
 {
     Energy energy = new Energy();
     energy.ID = id;
     energy.IsDeleted = isDeleted;
     return energy;
 }