Ejemplo n.º 1
0
        public static DPoleSection AccessSelectByProductCodeProductType(Guid ProductCode, int ProductType)
        {
            OleDbConnection connection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);
            OleDbCommand    command    = new OleDbCommand("D_PoleSection_SelectByProductCodeProductType", connection);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new OleDbParameter("iProductCode", ProductCode));

            command.Parameters.Add(new OleDbParameter("iProductType", ProductType));
            //command.Parameters.Add(new OleDbParameter("iDesignCode", DesignCode));
            DPoleSection dPoleSection = new DPoleSection();

            try
            {
                connection.Open();
                OleDbDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    dPoleSection.Code = Convert.ToInt32(reader["Code"]);
                    //dPoleSection.DesignCode = Convert.ToInt32(reader["DesignCode"]);
                    dPoleSection.ProductCode = new Guid(reader["ProductCode"].ToString());
                    dPoleSection.ProductType = Convert.ToInt32(reader["ProductType"]);
                    dPoleSection.SectionCode = new Guid(reader["SectionCode"].ToString());
                }
                else
                {
                    dPoleSection.SectionCode = Guid.Empty;
                }

                reader.Close();
                connection.Close();
            }
            catch (System.Exception ex1)
            {
                Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage(string.Format(" ERROR D_PoleSection_SelectByDesignCodeProductCodeProductType {0}\n", ex1.Message));
                connection.Close();
            }
            return(dPoleSection);
            //SqlConnection connection = new SqlConnection(Atend.Control.ConnectionString.cnString);
            //SqlDataAdapter adapter = new SqlDataAdapter("D_PoleSection_SelectByDesignCodeProductCodeProductType", connection);
            //adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            //adapter.SelectCommand.Parameters.Add(new SqlParameter("iProductType", ProductType));
            //adapter.SelectCommand.Parameters.Add(new SqlParameter("iDesignCode", DesignCode));
            //adapter.SelectCommand.Parameters.Add(new SqlParameter("iProductCode", ProductType));

            //DataSet dsPoleSection = new DataSet();
            //adapter.Fill(dsPoleSection);
            //return dsPoleSection.Tables[0];
        }
Ejemplo n.º 2
0
        //*******************Access To Memory For Calc
        public static DPoleSection AccessSelectByProductCodeProductType(DataTable dtPoleSection, Guid ProductCode, int ProductType)
        {
            DataRow[]    dr           = dtPoleSection.Select(string.Format("ProductCode='{0}' AND ProductType={1}", ProductCode, ProductType));
            DPoleSection dPoleSection = new DPoleSection();

            if (dr.Length != 0)
            {
                dPoleSection.Code = Convert.ToInt32(dr[0]["Code"]);
                //dPoleSection.DesignCode = Convert.ToInt32(reader["DesignCode"]);
                dPoleSection.ProductCode = new Guid(dr[0]["ProductCode"].ToString());
                dPoleSection.ProductType = Convert.ToInt32(dr[0]["ProductType"]);
                dPoleSection.SectionCode = new Guid(dr[0]["SectionCode"].ToString());
            }
            else
            {
                dPoleSection.SectionCode = Guid.Empty;
            }

            return(dPoleSection);
        }