コード例 #1
0
        private CategoryInfo RowToCategoryInfo(DataRow dr)
        {
            CategoryInfo ct = new CategoryInfo();
            //if(tp==1)
            //{
            ct.CatId = Convert.ToInt32(dr["CatId"]);
            //}

            ct.CatName = dr["CatName"].ToString();
            ct.CatNum = Convert.ToInt32(dr["CatNum"]);
            ct.Remark = dr["Remark"].ToString();
            return ct;
        }
コード例 #2
0
 public bool SaveCategoryInfo(CategoryInfo ct,int temp)
 {
     int r = -1;
     if(temp == 1)
     {
         //insert
         r = dal.AddCategoryInfo(ct);
     }
     else if(temp == 2)
     {
         //Update
         r = dal.UpdateCategoryInfo(ct);
     }
     return r > 0;
 }
コード例 #3
0
 private int AddAndUpdateCategoryInfo(string sql, int temp, CategoryInfo ct)
 {
     SQLiteParameter[] ps ={
                              new SQLiteParameter("@CatName",ct.CatName),
                              new SQLiteParameter("@CatNum",ct.CatNum),
                              new SQLiteParameter("@Remark",ct.Remark)
                          };
     List<SQLiteParameter> list = new List<SQLiteParameter>();
     list.AddRange(ps);
     if(temp == 1)
     {
         //Insert
         list.Add(new SQLiteParameter("@DelFlag", ct.DelFlag));
         list.Add(new SQLiteParameter("@SubTime", ct.SubTime));
         list.Add(new SQLiteParameter("@SubBy", ct.SubBy));
     }
     else if(temp == 2)
     {
         //Update
         list.Add(new SQLiteParameter("@CatId", ct.CatId));
     }
     return SqliteHelper.ExecuteNonQuery(sql, list.ToArray());
 }
コード例 #4
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     if(CheckEmpty())
     {
         CategoryInfo ct = new CategoryInfo();
         ct.CatName = txtCName.Text;
         ct.CatNum = Convert.ToInt32(txtCNum.Text);
         ct.Remark = txtCRemark.Text;
         if(this.Tp == 1)
         {
             ct.DelFlag = 0;
             ct.SubBy = 1;
             ct.SubTime = DateTime.Now;
         }
         else if(this.Tp == 2)
         {
             ct.CatId = Convert.ToInt32(labId.Text);
         }
         CategoryInfoBLL bll = new CategoryInfoBLL();
         string msg = bll.SaveCategoryInfo(ct, this.Tp) ? "操作成功" : "操作失败";
         MessageBox.Show(msg);
         this.Close();
     }
 }
コード例 #5
0
 public int UpdateCategoryInfo(CategoryInfo ct)
 {
     string sql = "update CategoryInfo set CatName=@CatName,CatNum=@CatNum,Remark=@Remark where CatId=@CatId";
     return AddAndUpdateCategoryInfo(sql, 2, ct);
 }
コード例 #6
0
 public int AddCategoryInfo(CategoryInfo ct)
 {
     string sql = "insert into CategoryInfo (CatName,CatNum,Remark,DelFlag,SubTime,SubBy) values(@CatName,@CatNum,@Remark,@DelFlag,@SubTime,@SubBy)";
     return AddAndUpdateCategoryInfo(sql, 1, ct);
 }