Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (bll.IsExit(txtName.Text.Trim()))
            {
                MessageBox.Show("名称重复!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                try
                {
                    T_JB_PLACEAREA mo = new T_JB_PLACEAREA();

                    mo.C_NAME = txtName.Text.Trim();
                    mo.C_MEMO = txtMemo.Text.Trim();

                    if (bll.Save(mo))
                    {
                        MessageBox.Show("保存成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Log.saveLog("添加货区成功!Id:" + lblId.Text);
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("保存失败!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据id获得实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public T_JB_PLACEAREA GetById(string id)
        {
            T_JB_PLACEAREA mo = new T_JB_PLACEAREA();
            DataRow        dr = GetById(tableName, id);

            mo.C_ID   = dr["C_ID"].ToString();
            mo.C_NAME = dr["C_NAME"].ToString();
            mo.C_MEMO = dr["C_MEMO"].ToString();

            return(mo);
        }
Exemplo n.º 3
0
        public bool Save(T_JB_PLACEAREA mo)
        {
            try
            {
                long   dec_id = 0;
                string c_id   = string.Empty;
                int    count  = 0;
                string sql    = "SELECT max(c_id) FROM " + tableName;

                object obj = dbHelper.GetScalar(sql);
                dec_id = Convert.IsDBNull(obj) ? 0 : Convert.ToInt64(obj);

                sql =
                    "INSERT INTO " + "[" + tableName +
                    "] ([C_ID],[C_NAME],[C_MEMO])" +
                    "VALUES (@C_ID,@C_NAME,@C_MEMO)";

                Hashtable table = new Hashtable();

                mo.C_ID = (dec_id + 1).ToString().PadLeft(4, '0');

                table.Add("C_ID", mo.C_ID);
                table.Add("C_NAME", mo.C_NAME);
                table.Add("C_MEMO", mo.C_MEMO);

                DbParameter[] parms = dbHelper.getParams(table);

                count = dbHelper.ExecuteCommand(sql, parms);
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Log.write(ex.Message + "\r\n" + ex.StackTrace);
                throw ex;
            }
            finally
            {
                dbHelper.getConnection().Close();
            }
        }
Exemplo n.º 4
0
        public bool Update(T_JB_PLACEAREA mo)
        {
            try
            {
                string sql =
                    "UPDATE  " + "[" + tableName +
                    "] SET [C_NAME] = @C_NAME, " +
                    "[C_MEMO] = @C_MEMO " +
                    "WHERE [C_ID] = @C_ID ";

                Hashtable table = new Hashtable();

                table.Add("C_ID", mo.C_ID);
                table.Add("C_NAME", mo.C_NAME);
                table.Add("C_MEMO", mo.C_MEMO);


                DbParameter[] parms = dbHelper.getParams(table);

                int count = dbHelper.ExecuteCommand(sql, parms);

                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Log.write(ex.Message + "\r\n" + ex.StackTrace);
                throw ex;
            }
            finally
            {
                dbHelper.getConnection().Close();
            }
        }
Exemplo n.º 5
0
        private void Init()
        {
            try
            {
                T_JB_PLACEAREA mo = bll.GetById(id);

                if (mo == null)
                {
                    MessageBox.Show("获取信息失败!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.Close();
                }
                else
                {
                    lblId.Text   = mo.C_ID;
                    txtName.Text = mo.C_NAME;
                    txtMemo.Text = mo.C_MEMO;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
 public bool Update(T_JB_PLACEAREA mo)
 {
     return(dal.Update(mo));
 }
Exemplo n.º 7
0
 public bool Save(T_JB_PLACEAREA mo)
 {
     return(dal.Save(mo));
 }