Beispiel #1
0
        public Int32 Insert(AccessGroupDetails Details)
        {
            try
            {
                // Aug 2, 2014 : change to save only
                Details.CreatedOn    = Details.CreatedOn == Constants.C_DATE_MIN_VALUE ? DateTime.Now : Details.CreatedOn;
                Details.LastModified = Details.LastModified == Constants.C_DATE_MIN_VALUE ? DateTime.Now : Details.LastModified;

                Save(Details);

                string SQL = "INSERT INTO sysAccessGroups (GroupName, Remarks) VALUES (@GroupName, @Remarks);";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                //MySqlParameter prmGroupName = new MySqlParameter("@GroupName",MySqlDbType.String);
                //prmGroupName.Value = Details.GroupName;
                //cmd.Parameters.Add(prmGroupName);

                //MySqlParameter prmRemarks = new MySqlParameter("@Remarks",MySqlDbType.String);
                //prmRemarks.Value = Details.Remarks;
                //cmd.Parameters.Add(prmRemarks);

                //base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);


                Int32 iID = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int32.Parse(dr[0].ToString());
                }

                return(iID);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Beispiel #2
0
		public Int32 Insert(AccessGroupDetails Details)
		{
			try 
			{
                // Aug 2, 2014 : change to save only
                Details.CreatedOn = Details.CreatedOn == Constants.C_DATE_MIN_VALUE ? DateTime.Now : Details.CreatedOn;
                Details.LastModified = Details.LastModified == Constants.C_DATE_MIN_VALUE ? DateTime.Now : Details.LastModified;

                Save(Details);

                string SQL = "INSERT INTO sysAccessGroups (GroupName, Remarks) VALUES (@GroupName, @Remarks);";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;
				
                //MySqlParameter prmGroupName = new MySqlParameter("@GroupName",MySqlDbType.String);			
                //prmGroupName.Value = Details.GroupName;
                //cmd.Parameters.Add(prmGroupName);

                //MySqlParameter prmRemarks = new MySqlParameter("@Remarks",MySqlDbType.String);
                //prmRemarks.Value = Details.Remarks;
                //cmd.Parameters.Add(prmRemarks);

                //base.ExecuteNonQuery(cmd);

				SQL = "SELECT LAST_INSERT_ID();";
				
				cmd.Parameters.Clear(); 
				cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);


                Int32 iID = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int32.Parse(dr[0].ToString());
                }

				return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Beispiel #3
0
        public AccessGroupDetails Details(Int32 GroupID)
        {
            try
            {
                string SQL = "SELECT " +
                             "GroupID, " +
                             "GroupName, " +
                             "Remarks " +
                             "FROM sysAccessGroups " +
                             "WHERE GroupID = @GroupID;";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmGroupID = new MySqlParameter("@GroupID", MySqlDbType.Int16);
                prmGroupID.Value = GroupID;
                cmd.Parameters.Add(prmGroupID);

                MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);

                AccessGroupDetails Details = new AccessGroupDetails();

                while (myReader.Read())
                {
                    Details.GroupID   = GroupID;
                    Details.GroupName = "" + myReader["GroupName"].ToString();
                    Details.Remarks   = "" + myReader["Remarks"].ToString();
                }

                myReader.Close();

                return(Details);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Beispiel #4
0
        public void Update(AccessGroupDetails Details)
        {
            try
            {
                // Aug 2, 2014 : change to save only
                Details.CreatedOn    = Details.CreatedOn == Constants.C_DATE_MIN_VALUE ? DateTime.Now : Details.CreatedOn;
                Details.LastModified = Details.LastModified == Constants.C_DATE_MIN_VALUE ? DateTime.Now : Details.LastModified;

                Save(Details);

                //string SQL=	"UPDATE sysAccessGroups SET " +
                //            "GroupName = @GroupName," +
                //            "Remarks = @Remarks " +
                //            "WHERE GroupID = @GroupID;";

                //MySqlCommand cmd = new MySqlCommand();
                //cmd.CommandType = System.Data.CommandType.Text;
                //cmd.CommandText = SQL;

                //MySqlParameter prmGroupName = new MySqlParameter("@GroupName",MySqlDbType.String);
                //prmGroupName.Value = Details.GroupName;
                //cmd.Parameters.Add(prmGroupName);

                //MySqlParameter prmRemarks = new MySqlParameter("@Remarks",MySqlDbType.String);
                //prmRemarks.Value = Details.Remarks;
                //cmd.Parameters.Add(prmRemarks);

                //MySqlParameter prmGroupID = new MySqlParameter("@GroupID",MySqlDbType.Int16);
                //prmGroupID.Value = Details.GroupID;
                //cmd.Parameters.Add(prmGroupID);

                //base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Beispiel #5
0
        public Int32 Save(AccessGroupDetails Details)
        {
            try
            {
                string SQL = "CALL procSaveSysAccessGroups(@GroupID, @GroupName, @Remarks, @CreatedOn, @LastModified);";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                cmd.Parameters.AddWithValue("GroupName", Details.GroupName);
                cmd.Parameters.AddWithValue("Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("CreatedOn", Details.CreatedOn == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.CreatedOn);
                cmd.Parameters.AddWithValue("LastModified", Details.LastModified == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.LastModified);

                return(base.ExecuteNonQuery(cmd));
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Beispiel #6
0
		public AccessGroupDetails Details(Int32 GroupID)
		{
			try
			{
				string SQL=	"SELECT " +
								"GroupID, " +
								"GroupName, " +
								"Remarks " +
							"FROM sysAccessGroups " +
							"WHERE GroupID = @GroupID;";
				  
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

				MySqlParameter prmGroupID = new MySqlParameter("@GroupID",MySqlDbType.Int16);
				prmGroupID.Value = GroupID;
				cmd.Parameters.Add(prmGroupID);

				MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);
				
				AccessGroupDetails Details = new AccessGroupDetails();

				while (myReader.Read()) 
				{
					Details.GroupID = GroupID;
					Details.GroupName = "" + myReader["GroupName"].ToString();
					Details.Remarks = "" + myReader["Remarks"].ToString();
				}

				myReader.Close();

				return Details;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Beispiel #7
0
        public Int32 Save(AccessGroupDetails Details)
        {
            try
            {
                string SQL = "CALL procSaveSysAccessGroups(@GroupID, @GroupName, @Remarks, @CreatedOn, @LastModified);";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                cmd.Parameters.AddWithValue("GroupName", Details.GroupName);
                cmd.Parameters.AddWithValue("Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("CreatedOn", Details.CreatedOn == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.CreatedOn);
                cmd.Parameters.AddWithValue("LastModified", Details.LastModified == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.LastModified);

                return base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Beispiel #8
0
		public void Update(AccessGroupDetails Details)
		{
			try 
			{
                // Aug 2, 2014 : change to save only
                Details.CreatedOn = Details.CreatedOn == Constants.C_DATE_MIN_VALUE ? DateTime.Now : Details.CreatedOn;
                Details.LastModified = Details.LastModified == Constants.C_DATE_MIN_VALUE ? DateTime.Now : Details.LastModified;

                Save(Details);

                //string SQL=	"UPDATE sysAccessGroups SET " + 
                //            "GroupName = @GroupName," +  
                //            "Remarks = @Remarks " + 
                //            "WHERE GroupID = @GroupID;";
				  
                //MySqlCommand cmd = new MySqlCommand();
                //cmd.CommandType = System.Data.CommandType.Text;
                //cmd.CommandText = SQL;
				
                //MySqlParameter prmGroupName = new MySqlParameter("@GroupName",MySqlDbType.String);			
                //prmGroupName.Value = Details.GroupName;
                //cmd.Parameters.Add(prmGroupName);

                //MySqlParameter prmRemarks = new MySqlParameter("@Remarks",MySqlDbType.String);
                //prmRemarks.Value = Details.Remarks;
                //cmd.Parameters.Add(prmRemarks);

                //MySqlParameter prmGroupID = new MySqlParameter("@GroupID",MySqlDbType.Int16);			
                //prmGroupID.Value = Details.GroupID;
                //cmd.Parameters.Add(prmGroupID);

                //base.ExecuteNonQuery(cmd);
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}