コード例 #1
0
        private void btnOk_Click_1(object sender, EventArgs e)
        {
            if (CheckEmpty())//判断所有的文本框不为空
            {
                CategoryInfoBll cBll = new CategoryInfoBll();
                CategoryInfo c = new CategoryInfo();
                c.CName = txtCName.Text;//名字
                c.CNum = txtCNum.Text;//编号
                c.CRemark = txtCRemark.Text;//备注

                //判断是新增还是修改
                if (Temp == 1)//新增
                {
                    c.DelFlag = 0;
                    c.SubBy = 1;
                    c.SubTime = System.DateTime.Now;//提交时间
                }//修改
                else if (Temp == 2)
                {
                    c.CId = Convert.ToInt32(labId.Text);//id类别
                }
                string msg = cBll.AddOrUpdateCategoryInfo(c, Temp) ? "操作成功" : "操作失败";
                md.MsgDivShow(msg, 1, Bind);
               // md.MsgDivShow(msg, 1);
            }
        }
コード例 #2
0
 public static FrmCategoryAddOrModify Single(int temp, CategoryInfo c)
 {
     if (_instance == null || _instance.IsDisposed)
     {
         _instance = new FrmCategoryAddOrModify(c);
         Temp = temp;
     }
     return _instance;
 }
コード例 #3
0
 /// <summary>
 /// 新增或者是修改商品类别信息
 /// </summary>
 /// <param name="c">商品类别对象</param>
 /// <param name="temp">标识:1----新增,2----修改</param>
 /// <returns>是否成功</returns>
 public bool AddOrUpdateCategoryInfo(CategoryInfo c, int temp)
 {
     if (temp == 1)//新增
     {
         return cDal.AddCategoryInfo(c) > 0;
     }
     else if (temp == 2)//修改
     {
         return cDal.UpdateCategoryInfo(c) > 0;
     }
     return false;
 }
コード例 #4
0
        private FrmCategoryAddOrModify(CategoryInfo c)
        {
            InitializeComponent();

            //为文本框赋值
            if (c != null)//修改
            {
                txtCName.Text = c.CName;//名字
                txtCNum.Text = c.CNum;//编号
                txtCRemark.Text = c.CRemark;//备注
                labId.Text = c.CId.ToString();//类别的id
            }
        }
コード例 #5
0
 private int AddOrUpdateCategoryInfo(CategoryInfo c, string sql, int temp)
 {
     List<SqlParameter> list = new List<SqlParameter>();
     SqlParameter[] ps = {
            new SqlParameter("@CName",c.CName),
            new SqlParameter("@CNum",c.CNum),
            new SqlParameter("@CRemark",c.CRemark)
                        };
     list.AddRange(ps);
     if (temp == 1)//新增
     {
         list.Add(new SqlParameter("@DelFlag", c.DelFlag));
         list.Add(new SqlParameter("@SubTime", c.SubTime));
         list.Add(new SqlParameter("@SubBy", c.SubBy));
     }
     else if (temp == 2)//修改
     {
         list.Add(new SqlParameter("@CId", c.CId));
     }
     return SqlHelper.ExecuteNonQuery(sql, list.ToArray());
 }
コード例 #6
0
 private void ShowFrmCategoryAddOrModify(int temp, CategoryInfo c)
 {
     this.Hide();
     FrmCategoryAddOrModify fcam = FrmCategoryAddOrModify.Single(temp, c);
     fcam.FormClosed += new FormClosedEventHandler(fcam_FormClosed);
     fcam.Show();//显示商品类别信息新增或者修改的窗体
 }
コード例 #7
0
 //关系转对象
 private CategoryInfo RowToCategoryInfoByDataRow(DataRow dr)
 {
     CategoryInfo c = new CategoryInfo();
     c.CId = Convert.ToInt32(dr["CId"]);
     c.CName = dr["CName"].ToString();
     c.CNum = dr["CNum"].ToString();
     c.CRemark = dr["CRemark"].ToString();
     c.DelFlag = Convert.ToInt32(dr["DelFlag"]);
     c.SubBy = Convert.ToInt32(dr["SubBy"]);
     c.SubTime = Convert.ToDateTime(dr["SubTime"]);
     return c;
 }
コード例 #8
0
 //修改
 public int UpdateCategoryInfo(CategoryInfo c)
 {
     string sql = "update CategoryInfo set CName=@CName, CNum=@CNum, CRemark=@CRemark where CId=@CId";
     return AddOrUpdateCategoryInfo(c, sql, 2);//新增
 }
コード例 #9
0
 //新增
 public int AddCategoryInfo(CategoryInfo c)
 {
     string sql = "insert into CategoryInfo(CName, CNum, CRemark, DelFlag, SubTime, SubBy)values(@CName, @CNum, @CRemark, @DelFlag, @SubTime, @SubBy)";
     return AddOrUpdateCategoryInfo(c, sql, 1);//新增
 }