Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        //public Maticsoft.Model.tb_KuWei GetModel(string KuWeiName,string X,string Y,string Z)
        public Maticsoft.Model.tb_KuWei GetModel(string KuWeiName)
        {
            StringBuilder strSql = new StringBuilder();

            //strSql.Append("select KuWeiName, X, Y, Z  ");
            strSql.Append("select  *  ");
            strSql.Append("  from tb_KuWei ");
            //strSql.Append(" where KuWeiName=@KuWeiName and X=@X and Y=@Y and Z=@Z ");
            strSql.Append(" where KuWeiName=@KuWeiName  ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@KuWeiName", SqlDbType.VarChar, 50)
                //,
                //new SqlParameter("@X", SqlDbType.VarChar,50),
                //new SqlParameter("@Y", SqlDbType.VarChar,50),
                //new SqlParameter("@Z", SqlDbType.VarChar,50)
            };
            parameters[0].Value = KuWeiName;
            //parameters[1].Value = X;
            //parameters[2].Value = Y;
            //parameters[3].Value = Z;


            Maticsoft.Model.tb_KuWei model = new Maticsoft.Model.tb_KuWei();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.KuWeiName = ds.Tables[0].Rows[0]["KuWeiName"].ToString();
                model.X         = ds.Tables[0].Rows[0]["X"].ToString();
                model.Y         = ds.Tables[0].Rows[0]["Y"].ToString();
                model.Z         = ds.Tables[0].Rows[0]["Z"].ToString();
                model.Precision = ds.Tables[0].Rows[0]["Precision"].ToString();


                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateRead(Maticsoft.Model.tb_KuWei model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_DingDian set ");

            //strSql.Append(" KuWeiName = @KuWeiName , ");
            strSql.Append(" X = @X , ");
            strSql.Append(" Y = @Y , ");
            strSql.Append(" Z = @Z  ");
            //strSql.Append(" precision = @Precision ");
            //strSql.Append(" where KuWeiName=@KuWeiName and X=@X and Y=@Y and Z=@Z  ");
            strSql.Append(" where DingDianName=@DingDianName ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DingDianName", SqlDbType.VarChar, 50),
                new SqlParameter("@X",            SqlDbType.VarChar, 50),
                new SqlParameter("@Y",            SqlDbType.VarChar, 50),
                new SqlParameter("@Z",            SqlDbType.VarChar, 50),
                //new SqlParameter("@Precision", SqlDbType.VarChar,50)
            };

            parameters[0].Value = model.KuWeiName;
            parameters[1].Value = model.X;
            parameters[2].Value = model.Y;
            parameters[3].Value = model.Z;
            //parameters[4].Value = model.Precision;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 private void dataGridViewKuWei_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         tb_KuWeiModel = tb_KuWeiBLL.GetModel(dataGridViewKuWei.SelectedRows[0].Cells[0].Value.ToString()
                                              //,
                                              //dataGridViewKuWei.SelectedRows[0].Cells[1].Value.ToString(),
                                              //dataGridViewKuWei.SelectedRows[0].Cells[2].Value.ToString(),
                                              //dataGridViewKuWei.SelectedRows[0].Cells[3].Value.ToString()
                                              );
         txtKuWeiName.ReadOnly = false;
         txtKuWeiName.Text     = tb_KuWeiModel.KuWeiName;
         txtKuWeiName.ReadOnly = true;
         txtX.Text             = tb_KuWeiModel.X;
         tXtY.Text             = tb_KuWeiModel.Y;
         txtZ.Text             = tb_KuWeiModel.Z;
         kuweiPrecision.Text   = tb_KuWeiModel.Precision;
     }
     catch (Exception ex)
     {
         //throw;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Maticsoft.Model.tb_KuWei model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_KuWei(");
            strSql.Append("KuWeiName,X,Y,Z");
            strSql.Append(") values (");
            strSql.Append("@KuWeiName,@X,@Y,@Z");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@KuWeiName", SqlDbType.VarChar, 50),
                new SqlParameter("@X",         SqlDbType.VarChar, 50),
                new SqlParameter("@Y",         SqlDbType.VarChar, 50),
                new SqlParameter("@Z",         SqlDbType.VarChar, 50)
            };

            parameters[0].Value = model.KuWeiName;
            parameters[1].Value = model.X;
            parameters[2].Value = model.Y;
            parameters[3].Value = model.Z;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }