public bool AddMGroup(MGroup mgroup) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "AddMGroup"; cmd.Parameters.AddWithValue("@GroupNo", mgroup.GroupNo); cmd.Parameters.AddWithValue("@GroupName", mgroup.GroupName); cmd.Parameters.AddWithValue("@ControlGroup", mgroup.ControlGroup); cmd.Parameters.AddWithValue("@SignCode", mgroup.SignCode); cmd.Parameters.AddWithValue("@IsActive", mgroup.IsActive); cmd.Parameters.AddWithValue("@UserID", mgroup.UserID); cmd.Parameters.AddWithValue("@UserDate", mgroup.UserDate); //cmd.Parameters.AddWithValue("@ModifiedBy", mgroup.ModifiedBy); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { mgroup.msg = ObjTrans.ErrorMessage; return(false); } }
public MGroup ModifyMGroupByID(long ID) { SqlConnection Con = new SqlConnection(CommonFunctions.ConStr); string sql; SqlCommand cmd; sql = "Select * from MGroup where GroupNo =" + ID; cmd = new SqlCommand(sql, Con); cmd.Connection = Con; Con.Open(); cmd.CommandType = CommandType.Text; SqlDataReader dr; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (dr.HasRows) { MGroup MM = new MGroup(); while (dr.Read()) { MM.GroupNo = Convert.ToInt32(dr["GroupNo"]); if (!Convert.IsDBNull(dr["GroupName"])) { MM.GroupName = Convert.ToString(dr["GroupName"]); } if (!Convert.IsDBNull(dr["ControlGroup"])) { MM.ControlGroup = Convert.ToInt64(dr["ControlGroup"]); } if (!Convert.IsDBNull(dr["SignCode"])) { MM.SignCode = Convert.ToInt64(dr["SignCode"]); } if (!Convert.IsDBNull(dr["IsActive"])) { MM.IsActive = Convert.ToBoolean(dr["IsActive"]); } if (!Convert.IsDBNull(dr["UserID"])) { MM.UserID = Convert.ToInt64(dr["UserID"]); } if (!Convert.IsDBNull(dr["UserDate"])) { MM.UserDate = Convert.ToDateTime(dr["UserDate"]); } if (!Convert.IsDBNull(dr["ModifiedBy"])) { MM.ModifiedBy = Convert.ToString(dr["ModifiedBy"]); } } dr.Close(); return(MM); } else { dr.Close(); } return(new MGroup()); }
public bool DeleteMGroup(MGroup mgroup) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DeleteMGroup"; cmd.Parameters.AddWithValue("@GroupNo", mgroup.GroupNo); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { mgroup.msg = ObjTrans.ErrorMessage; return(false); } }