Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                decimal aaa  = Convert.ToDecimal(textBox1.Text.Trim());
                decimal bbbb = Convert.ToDecimal(textBox2.Text.Trim());
            }
            catch
            {
                MessageBox.Show("换算率只能是数字");
                return;
            }
            Hownet.Model.OtherType modOT = bllOT.GetModel(Convert.ToInt32(Convert.ToInt32(dtOT.Select("(Name='默认单位')")[0]["ID"])));
            modOT.Value = comboBox1.SelectedValue.ToString();
            bllOT.Update(modOT);

            modOT       = bllOT.GetModel(Convert.ToInt32(Convert.ToInt32(dtOT.Select("(Name='车间单位')")[0]["ID"])));
            modOT.Value = comboBox2.SelectedValue.ToString();
            bllOT.Update(modOT);

            modOT       = bllOT.GetModel(Convert.ToInt32(Convert.ToInt32(dtOT.Select("(Name='仓储单位')")[0]["ID"])));
            modOT.Value = comboBox3.SelectedValue.ToString();
            bllOT.Update(modOT);

            modOT       = bllOT.GetModel(Convert.ToInt32(Convert.ToInt32(dtOT.Select("(Name='车间换算')")[0]["ID"])));
            modOT.Value = textBox1.Text.Trim();
            bllOT.Update(modOT);

            modOT       = bllOT.GetModel(Convert.ToInt32(Convert.ToInt32(dtOT.Select("(Name='仓储换算')")[0]["ID"])));
            modOT.Value = textBox2.Text.Trim();
            bllOT.Update(modOT);
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hownet.Model.OtherType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OtherType(");
            strSql.Append("Name,TypeID,Value)");
            strSql.Append(" values (");
            strSql.Append("@Name,@TypeID,@Value)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",   SqlDbType.NVarChar, 255),
                new SqlParameter("@TypeID", SqlDbType.Int,        4),
                new SqlParameter("@Value",  SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.TypeID;
            parameters[2].Value = model.Value;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hownet.Model.OtherType GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Name,TypeID,Value from OtherType ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                if (ds.Tables[0].Rows[0]["TypeID"].ToString() != "")
                {
                    model.TypeID = int.Parse(ds.Tables[0].Rows[0]["TypeID"].ToString());
                }
                model.Value = ds.Tables[0].Rows[0]["Value"].ToString();
                model.A     = 1;
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        private void frFinishedMeasure_Load(object sender, EventArgs e)
        {
            dtMea = bllMea.GetAllList().Tables[0];
            comboBox1.DataSource = dtMea.Copy();
            comboBox2.DataSource = dtMea.Copy();
            comboBox3.DataSource = dtMea.Copy();
            dtOT = bllOT.GetTypeList("成品单位").Tables[0];
            if (dtOT.Rows.Count == 0)
            {
                Hownet.Model.OtherType modOT = new Hownet.Model.OtherType();
                modOT.A      = 1;
                modOT.Name   = "成品单位";
                modOT.TypeID = 0;
                modOT.Value  = "0";
                int _id = bllOT.Add(modOT);
                modOT.TypeID = _id;
                modOT.Name   = "默认单位";
                modOT.Value  = "1";
                bllOT.Add(modOT);

                modOT.TypeID = _id;
                modOT.Name   = "仓储单位";
                bllOT.Add(modOT);

                modOT.TypeID = _id;
                modOT.Name   = "仓储换算";
                bllOT.Add(modOT);

                modOT.TypeID = _id;
                modOT.Name   = "车间单位";
                bllOT.Add(modOT);

                modOT.TypeID = _id;
                modOT.Name   = "车间换算";
                bllOT.Add(modOT);
                dtOT = bllOT.GetTypeList("成品单位").Tables[0];
            }
            li = bllOT.DataTableToList(dtOT);
            comboBox1.SelectedValue = Convert.ToInt32(dtOT.Select("(Name='默认单位')")[0]["Value"]);
            comboBox2.SelectedValue = Convert.ToInt32(dtOT.Select("(Name='车间单位')")[0]["Value"]);
            comboBox3.SelectedValue = Convert.ToInt32(dtOT.Select("(Name='仓储单位')")[0]["Value"]);
            textBox1.Text           = dtOT.Select("(Name='车间换算')")[0]["Value"].ToString();
            textBox2.Text           = dtOT.Select("(Name='仓储换算')")[0]["Value"].ToString();
            if (bllPA.GetAllList().Tables[0].Rows.Count > 0)
            {
                comboBox1.Enabled = comboBox2.Enabled = comboBox3.Enabled = false;
            }
        }
Пример #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Hownet.Model.OtherType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OtherType set ");
            strSql.Append("Name=@Name,");
            strSql.Append("TypeID=@TypeID,");
            strSql.Append("Value=@Value");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",     SqlDbType.Int,        4),
                new SqlParameter("@Name",   SqlDbType.NVarChar, 255),
                new SqlParameter("@TypeID", SqlDbType.Int,        4),
                new SqlParameter("@Value",  SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.TypeID;
            parameters[3].Value = model.Value;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }