示例#1
0
 /// <summary>
 /// ویرایش
 /// </summary>
 /// <returns></returns>
 public bool Update(JDataBase tempDb)
 {
     try
     {
         JTruckTable PDT = new JTruckTable();
         PDT.SetValueProperty(this);
         if (PDT.Update(tempDb))
         {
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         JSystem.Except.AddException(ex);
         return(false);
     }
     finally
     {
     }
 }
示例#2
0
 /// <summary>
 /// درج
 /// </summary>
 /// <returns></returns>
 public int Insert(JDataBase tempDb)
 {
     try
     {
         JTruckTable JLT = new JTruckTable();
         JLT.SetValueProperty(this);
         Code = JLT.Insert(tempDb);
         if (Code > 0)
         {
             return(Code);
         }
         return(0);
     }
     catch (Exception ex)
     {
         JSystem.Except.AddException(ex);
         return(0);
     }
     finally
     {
         //tempDb.Dispose();
     }
 }
示例#3
0
        /// <summary>
        /// حذف
        /// </summary>
        /// <returns></returns>
        public bool Delete(JDataBase tempDb)
        {
            JTruckTable PDT = new JTruckTable();

            try
            {
                PDT.SetValueProperty(this);
                if (PDT.Delete(tempDb))
                {
                    return(true);
                }
                //Nodes.Delete(Nodes.CurrentNode);
                return(true);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(false);
            }
            finally
            {
                //Db.Dispose();
            }
        }
示例#4
0
        public bool Update(DataTable tmpdt)
        {
            JTruckTable PDT = new JTruckTable();
            JDataBase   db  = new JDataBase();

            try
            {
                if (tmpdt != null)
                {
                    db.beginTransaction("InsertTruck");
                    foreach (DataRow dr in tmpdt.Rows)
                    {
                        if (dr.RowState == DataRowState.Added)
                        {
                            Name      = dr["Name"].ToString();
                            StartDate = Convert.ToDateTime(dr["StartDate"]);
                            EndDate   = Convert.ToDateTime(dr["EndDate"]);
                            Price     = Convert.ToInt32(dr["Price"]);
                            Shortcut  = dr["Shortcut"].ToString();
                            Insert(db);
                            dr["Code"] = Code;
                            if (Code < 1)
                            {
                                return(false);
                            }
                        }
                        if (dr.RowState == DataRowState.Modified)
                        {
                            Name      = dr["Name"].ToString();
                            StartDate = JDateTime.GregorianDate(dr["StartDate"].ToString());
                            EndDate   = JDateTime.GregorianDate(dr["EndDate"].ToString());
                            Price     = Convert.ToInt32(dr["Price"]);
                            Shortcut  = dr["Shortcut"].ToString();
                            Code      = Convert.ToInt32(dr["Code"]);
                            if (!Update(db))
                            {
                                return(false);
                            }
                        }
                        if (dr.RowState == DataRowState.Deleted)
                        {
                            dr.RejectChanges();
                            Code = (int)dr["Code"];
                            GetData(Code);
                            if (!Delete(db))
                            {
                                return(false);
                            }
                            dr.Delete();
                        }
                    }
                    tmpdt.AcceptChanges();
                    if (db.Commit())
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                db.Rollback("InsertTruck");
                Except.AddException(ex);
                return(false);
            }
            finally
            {
                PDT.Dispose();
                db.Dispose();
            }
        }