Exemple #1
0
 private void setParameter(iSqlParameter[] parms, ItemcategoryInfo info)
 {
     try
     {
         int i = -1;
         parms[++i].Value = info.Iid;
         parms[++i].Value = info.Categoryid;
         parms[++i].Value = info.Belongto;
         return;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
 private ItemcategoryInfo getDataReader(iSqlDataReader dar)
 {
     try
     {
         int i = -1;
         ItemcategoryInfo info = new ItemcategoryInfo();
         info.Iid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i);
         info.Categoryid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i);
         info.Belongto = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i);
         return info;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
 private bool Saveitem(iSqlTransaction trans, ItemcategoryInfo info)
 {
     try
     {
         if (trans == null || info == null) return false;
         string SQL = SQL_INSERT;
         iSqlParameter[] parms = this.getParameter(SQL);
         this.setParameter(parms, info);
         HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms);
         return true;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #4
0
        public bool Save(int iid, int belongto, string categoryid)
        {
            try
            {
                using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM))
                {
                    using (iSqlTransaction trans = iConn.BeginTransaction())
                    {
                        try
                        {
                            if (this.Deleteitem(trans, iid, belongto))
                            {
                                if (!CFunctions.IsNullOrEmpty(categoryid))
                                {
                                    string[] strid = categoryid.Split(',');
                                    if (strid.Length > 0)
                                    {
                                        for (int i = 0; i < strid.Length; i++)
                                        {
                                            ItemcategoryInfo info = new ItemcategoryInfo();
                                            info.Iid = iid;
                                            info.Belongto = belongto;
                                            info.Categoryid = Convert.ToInt32(strid[i]);
                                            this.Saveitem(trans, info);
                                        }
                                    }
                                }
                            }

                            trans.Commit();
                        }
                        catch (Exception ex)
                        {
                            trans.Rollback();
                            throw ex;
                        }
                    }
                    iConn.Close();
                }
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }