public bool AddMStockCategory(MStockCategory mstockcategory) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "AddMStockCategory"; cmd.Parameters.AddWithValue("@CategoryNo", mstockcategory.CategoryNo); cmd.Parameters.AddWithValue("@CategoryName", mstockcategory.CategoryName); cmd.Parameters.AddWithValue("@ControlGroup", mstockcategory.ControlGroup); cmd.Parameters.AddWithValue("@DepartmentNo", mstockcategory.DepartmentNo); cmd.Parameters.AddWithValue("@IsActive", mstockcategory.IsActive); cmd.Parameters.AddWithValue("@UserId", mstockcategory.UserId); cmd.Parameters.AddWithValue("@UserDate", mstockcategory.UserDate); cmd.Parameters.AddWithValue("@CompanyNo", mstockcategory.CompanyNo); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { mstockcategory.msg = ObjTrans.ErrorMessage; return(false); } }
public bool DeleteMStockCategory(MStockCategory mstockcategory) { SqlCommand cmd; cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DeleteMStockCategory"; cmd.Parameters.AddWithValue("@CategoryNo", mstockcategory.CategoryNo); if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true) { return(true); } else { mstockcategory.msg = ObjTrans.ErrorMessage; return(false); } }
public MStockCategory ModifyMStockCategoryByID(long ID) { SqlConnection Con = new SqlConnection(CommonFunctions.ConStr); string sql; SqlCommand cmd; sql = "Select * from MStockCategory where CategoryNo =" + 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) { MStockCategory MM = new MStockCategory(); while (dr.Read()) { MM.CategoryNo = Convert.ToInt32(dr["CategoryNo"]); if (!Convert.IsDBNull(dr["CategoryName"])) { MM.CategoryName = Convert.ToString(dr["CategoryName"]); } if (!Convert.IsDBNull(dr["ControlGroup"])) { MM.ControlGroup = Convert.ToInt64(dr["ControlGroup"]); } if (!Convert.IsDBNull(dr["IsActive"])) { MM.IsActive = Convert.ToBoolean(dr["IsActive"]); } if (!Convert.IsDBNull(dr["DepartmentNo"])) { MM.DepartmentNo = Convert.ToInt64(dr["DepartmentNo"]); } 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"]); } if (!Convert.IsDBNull(dr["CompanyNo"])) { MM.CompanyNo = Convert.ToInt64(dr["CompanyNo"]); } } dr.Close(); return(MM); } else { dr.Close(); } return(new MStockCategory()); }