예제 #1
0
파일: tb_type.cs 프로젝트: uwitec/Wms-7
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.tb_type model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_type set ");
            if (model.t_paid != null)
            {
                strSql.Append("t_paid=" + model.t_paid + ",");
            }
            else
            {
                strSql.Append("t_paid= null ,");
            }
            if (model.t_no != null)
            {
                strSql.Append("t_no='" + model.t_no + "',");
            }
            else
            {
                strSql.Append("t_no= null ,");
            }
            if (model.t_name != null)
            {
                strSql.Append("t_name='" + model.t_name + "',");
            }
            if (model.t_desc != null)
            {
                strSql.Append("t_desc='" + model.t_desc + "',");
            }
            else
            {
                strSql.Append("t_desc= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where t_id=" + model.t_id + "");
            int rowsAffected = DbSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        private void dgvCellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            optrowid = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            if (!String.IsNullOrEmpty(optrowid))
            {
                model = dal.GetModel(int.Parse(optrowid));
                if (model != null)
                {
                    this.t_name.Text = model.t_name;

                    this.t_no.Text = model.t_no;
                }
            }
        }
예제 #3
0
파일: tb_type.cs 프로젝트: uwitec/Wms-7
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.tb_type model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.t_paid != null)
            {
                strSql1.Append("t_paid,");
                strSql2.Append("" + model.t_paid + ",");
            }
            if (model.t_no != null)
            {
                strSql1.Append("t_no,");
                strSql2.Append("'" + model.t_no + "',");
            }
            if (model.t_name != null)
            {
                strSql1.Append("t_name,");
                strSql2.Append("'" + model.t_name + "',");
            }
            if (model.t_desc != null)
            {
                strSql1.Append("t_desc,");
                strSql2.Append("'" + model.t_desc + "',");
            }
            strSql.Append("insert into tb_type(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
파일: tb_type.cs 프로젝트: uwitec/Wms-7
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.tb_type GetModel(int t_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" t_id,t_paid,t_no,t_name,t_desc ");
            strSql.Append(" from tb_type ");
            strSql.Append(" where t_id=" + t_id + "");
            Model.tb_type model = new Model.tb_type();
            DataSet       ds    = DbSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["t_id"] != null && ds.Tables[0].Rows[0]["t_id"].ToString() != "")
                {
                    model.t_id = int.Parse(ds.Tables[0].Rows[0]["t_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["t_paid"] != null && ds.Tables[0].Rows[0]["t_paid"].ToString() != "")
                {
                    model.t_paid = int.Parse(ds.Tables[0].Rows[0]["t_paid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["t_no"] != null && ds.Tables[0].Rows[0]["t_no"].ToString() != "")
                {
                    model.t_no = ds.Tables[0].Rows[0]["t_no"].ToString();
                }
                if (ds.Tables[0].Rows[0]["t_name"] != null && ds.Tables[0].Rows[0]["t_name"].ToString() != "")
                {
                    model.t_name = ds.Tables[0].Rows[0]["t_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["t_desc"] != null && ds.Tables[0].Rows[0]["t_desc"].ToString() != "")
                {
                    model.t_desc = ds.Tables[0].Rows[0]["t_desc"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
        private string getStr(int type, int id)
        {
            string reStr = "";

            if (type == 1)
            {
                molt  = new Model.tb_type();
                molt  = dalt.GetModel(id);
                reStr = molt != null ? molt.t_name : "";
            }
            else if (type == 2 || type == 3)
            {
                molk  = new Model.tb_ku();
                molk  = dalk.GetModel(id);
                reStr = molk != null ? molk.k_name : "";
            }
            else if (type == 4)
            {
                molr  = new Model.tb_ruzhu();
                molr  = dalr.GetModel(id);
                reStr = molr != null ? molr.r_name : "";
            }
            return(reStr);
        }
예제 #6
0
        private void tbBtnClick(object sender, ToolBarButtonClickEventArgs e)
        {
            if (e.Button.ToolTipText == "新增")
            {
                rstValue();
                setModifyMode(true);
                optrowid = null;
            }
            if (e.Button.ToolTipText == "修改")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    setModifyMode(true);
                }
                else
                {
                    MessageBox.Show("请选择所要修改的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "删除")
            {
                if (!String.IsNullOrEmpty(optrowid))
                {
                    DialogResult result = MessageBox.Show("确认删除?", "删除数据", MessageBoxButtons.OKCancel);
                    if (result == DialogResult.OK)
                    {
                        dal.Delete(int.Parse(optrowid));
                        rstValue();
                        MessageBox.Show("恭喜你,删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        bindData("");
                        setModifyMode(false);
                        optrowid = null;
                    }
                }
                else
                {
                    MessageBox.Show("请选择所要删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            if (e.Button.ToolTipText == "提交")
            {
                if (validateIput())
                {
                    model = new Model.tb_type();

                    if (!string.IsNullOrEmpty(optrowid))
                    {
                        model = dal.GetModel(int.Parse(optrowid));
                    }

                    model.t_name = this.t_name.Text;

                    model.t_no = this.t_no.Text;

                    if (String.IsNullOrEmpty(optrowid))
                    {
                        DataTable dt = dal.GetList(" t_name='" + model.t_name + "' or t_no='" + model.t_no + "' ").Tables[0];
                        if (dt.Rows.Count > 0)
                        {
                            MessageBox.Show("恭喜你,已存在该名称,请更换", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (dal.Add(model) > 0)
                        {
                            MessageBox.Show("恭喜你,新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rstValue();
                            bindData("");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                    else
                    {
                        if (dal.Update(model))
                        {
                            MessageBox.Show("恭喜你,修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rstValue();
                            bindData("");
                            setModifyMode(false);
                            optrowid = null;
                        }
                    }
                }
            }

            if (e.Button.ToolTipText == "取消")
            {
                bindData("");
                rstValue();
                setModifyMode(false);
                optrowid = null;
            }
            if (e.Button.ToolTipText == "退出")
            {
                this.Close();
            }
        }