/// <summary> /// 新增信息 /// </summary> /// <param name="projectInCost">模型载体</param> /// <returns>受影响行数</returns> public int InsProjectInCost(ProjectInCost projectInCost) { string sql = @"INSERT INTO T_ProjectInCost VALUES (@PIC_Code ,@PIC_Name ,@PIC_ParentId ,@PIC_Enable ,@PIC_Clear)"; SqlParameter[] sps = { new SqlParameter("@PIC_Code", XYEEncoding.strCodeHex(projectInCost.PIC_Code)), new SqlParameter("@PIC_Name", XYEEncoding.strCodeHex(projectInCost.PIC_Name)), new SqlParameter("@PIC_ParentId", XYEEncoding.strCodeHex(projectInCost.PIC_ParentId)), new SqlParameter("@PIC_Enable", projectInCost.PIC_Enable), new SqlParameter("@PIC_Clear", projectInCost.PIC_Clear) }; return(DbHelperSQL.ExecuteSql(sql, sps)); }
/// <summary> /// 查询所有信息 /// </summary> /// <returns>List集合</returns> public List <ProjectInCost> SelProjectInCost() { List <ProjectInCost> list = new List <ProjectInCost>(); string sql = "select * from T_ProjectInCost where PIC_Clear=1 and PIC_Enable=1"; SqlDataReader read = DbHelperSQL.ExecuteReader(sql); while (read.Read()) { ProjectInCost pic = new ProjectInCost() { PIC_ID = Convert.ToInt32(read["PIC_ID"]), PIC_Name = XYEEncoding.strHexDecode(read["PIC_Name"].ToString()), PIC_Code = XYEEncoding.strHexDecode(read["PIC_Code"].ToString()), PIC_ParentId = XYEEncoding.strHexDecode(read["PIC_ParentId"].ToString()), PIC_Clear = Convert.ToInt32(read["PIC_Clear"].ToString()), PIC_Enable = Convert.ToInt32(read["PIC_Enable"].ToString()) }; list.Add(pic); } return(list); }
/// <summary> /// 新增信息 /// </summary> /// <param name="projectCost">模型载体</param> /// <returns>受影响行数</returns> public int InsProjectInCost(ProjectInCost projectInCost) { return(pics.InsProjectInCost(projectInCost)); }
protected override void form_save_Click(object sender, EventArgs e) { if (InsTextIsNull() == false) { return; } ProjectInCost pic = null; ProjectInCostType pict = (ProjectInCostType)Owner; int result = 0; switch (state) { case 0: pic = new ProjectInCost() { PIC_Name = textBox1.Text.Trim(), PIC_Clear = 1, PIC_Enable = 1, PIC_Code = BuildCode.ModuleCode("PICNode"), PIC_ParentId = code }; try { result = micm.InsProjectInCost(pic); if (result > 0) { MessageBox.Show("保存成功"); pict.isflag = true; Close(); Dispose(); return; } else { MessageBox.Show("保存失败"); pict.isflag = false; return; } } catch (Exception ex) { MessageBox.Show("保存失败,请检查服务器连接并尝试重新保存.错误:" + ex.Message); } break; case 1: pic = new ProjectInCost() { PIC_Name = textBox1.Text.Trim(), PIC_Clear = 1, PIC_Enable = 1, PIC_Code = BuildCode.ModuleCode("PICNode"), PIC_ParentId = code }; try { result = micm.InsProjectInCost(pic); if (result > 0) { MessageBox.Show("保存成功"); pict.isflag = true; Close(); Dispose(); return; } else { MessageBox.Show("保存失败"); pict.isflag = false; return; } } catch (Exception ex) { MessageBox.Show("保存失败,请检查服务器连接并尝试重新保存.错误:" + ex.Message); } break; case 2: try { result = micm.UpdateNameProjectInCost(textBox1.Text, code, txtName); if (result > 0) { MessageBox.Show("保存成功"); pict.isflag = true; Close(); Dispose(); return; } else { MessageBox.Show("保存失败"); pict.isflag = false; return; } } catch (Exception ex) { MessageBox.Show("保存失败,请检查服务器连接并尝试重新保存.错误:" + ex.Message); } break; default: MessageBox.Show("选择错误"); break; } }