Пример #1
0
        //Hatami
        public static DConsol AccessSelectByCode(Guid _Code)
        {
            OleDbConnection connection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);
            OleDbCommand    command    = new OleDbCommand("D_Consol_SelectByCode", connection);

            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.Add(new OleDbParameter("iCode", _Code));
            //command.Parameters.Add(new OleDbParameter("iDesignCode", DesignCode));

            DConsol dconsol = new DConsol();

            try
            {
                connection.Open();
                OleDbDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    dconsol.Code        = new Guid(reader["Code"].ToString());
                    dconsol.ParentCode  = new Guid(reader["ParentCode"].ToString());
                    dconsol.ProductCode = Convert.ToInt32(reader["ProductCode"].ToString());
                    dconsol.LoadCode    = Convert.ToInt32(reader["LoadCode"]);
                }

                reader.Close();
                connection.Close();
            }
            catch (System.Exception ex1)
            {
                Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage(string.Format(" ERROR DConsol.SelectByCode {0}\n", ex1.Message));
                connection.Close();
            }
            return(dconsol);
        }
Пример #2
0
        //****************************Access To Memory For Calc
        //Hatami
        public static DConsol AccessSelectByCode(DataTable dtDConsol, Guid _Code)
        {
            DataRow[] dr      = dtDConsol.Select(string.Format("Code='{0}'", _Code.ToString()));
            Editor    ed      = Application.DocumentManager.MdiActiveDocument.Editor;
            DConsol   dconsol = new DConsol();

            if (dr.Length != 0)
            {
                dconsol.Code        = new Guid(dr[0]["Code"].ToString());
                dconsol.ParentCode  = new Guid(dr[0]["ParentCode"].ToString());
                dconsol.ProductCode = Convert.ToInt32(dr[0]["ProductCode"].ToString());
                dconsol.LoadCode    = Convert.ToInt32(dr[0]["LoadCode"]);
            }

            return(dconsol);
        }