Esempio n. 1
0
		private Int64 SaveRecord()
		{
			AccessUser clsAccessUser = new AccessUser();
			AccessUserDetails clsDetails = new AccessUserDetails();

			clsDetails.UserName  = txtUserName.Text;
			clsDetails.Password  = txtPassword.Text;
			clsDetails.Name = txtName.Text;
			clsDetails.CountryID = Convert.ToInt32(cboCountry.SelectedItem.Value); 
			clsDetails.Address1  = txtAddress1.Text;
			clsDetails.Address2  = txtAddress2.Text;
			clsDetails.City  = txtCity.Text;
			clsDetails.State = txtState.Text;
			clsDetails.OfficePhone = txtOfficePhone.Text;
			clsDetails.DirectPhone = txtDirectPhone.Text;
			clsDetails.HomePhone = txtHomePhone.Text;
			clsDetails.FaxPhone = txtFaxNumber.Text;
			clsDetails.MobilePhone = txtMobile.Text;
			clsDetails.EmailAddress = txtEmail.Text;
			clsDetails.GroupID = Convert.ToInt32(cboGroup.SelectedItem.Value);

			Int64 id = clsAccessUser.Insert(clsDetails);
			clsAccessUser.CommitAndDispose();
			return id;
		}
Esempio n. 2
0
        public Int32 Save(AccessUserDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "CALL procSaveSysAccessUsers(@UID, @UserName, @Password, @DateCreated, @Deleted, @CreatedOn, @LastModified);";

                cmd.Parameters.AddWithValue("UID", Details.UID);
                cmd.Parameters.AddWithValue("UserName", Details.UserName);
                cmd.Parameters.AddWithValue("Password", Details.Password);
                cmd.Parameters.AddWithValue("DateCreated", Details.DateCreated);
                cmd.Parameters.AddWithValue("Deleted", Details.Deleted);
                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);

                cmd.CommandText = SQL;
                return(base.ExecuteNonQuery(cmd));
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Esempio n. 3
0
        private void ManageSecurity()
        {
            Security.AccessUserDetails clsAccessUserDetails = (Security.AccessUserDetails)Session["AccessUserDetails"];
            AccessRights        clsAccessRights             = new AccessRights();
            AccessRightsDetails clsDetails = new AccessRightsDetails();

            clsDetails            = clsAccessRights.Details(clsAccessUserDetails.UID, (Int16)AccessTypes.Products);
            lnkProducts.Visible   = clsDetails.Read;
            lnkProductAdd.Visible = clsDetails.Write;

            clsDetails             = clsAccessRights.Details(clsAccessUserDetails.UID, (int)AccessTypes.SynchronizeBranchProducts);
            lnkSynchronize.Visible = clsDetails.Read;

            clsDetails         = clsAccessRights.Details(clsAccessUserDetails.UID, (Int16)AccessTypes.Contacts);
            lnkContact.Visible = clsDetails.Read;
            lnkRewards.Visible = clsDetails.Read;

            clsDetails = clsAccessRights.Details(clsAccessUserDetails.UID, (Int16)AccessTypes.InventoryList);
            lnkInventoryList.Visible = clsDetails.Read;

            clsDetails        = clsAccessRights.Details(clsAccessUserDetails.UID, (Int16)AccessTypes.StockTransactions);
            lnkStock.Visible  = clsDetails.Read;
            lnkUpload.Visible = clsDetails.Read;

            clsDetails = clsAccessRights.Details(clsAccessUserDetails.UID, (Int16)AccessTypes.AccessUsers);
            lnkAccessUserAdd.Visible = clsDetails.Write;

            clsDetails = clsAccessRights.Details(clsAccessUserDetails.UID, (Int16)AccessTypes.ReportFormat);
            lnkReceiptFormatEdit.Visible = clsDetails.Write;

            clsAccessRights.CommitAndDispose();
        }
Esempio n. 4
0
        public AccessUserDetails Details(Int64 UID)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = SQLSelect() + "WHERE a.UID = @UID;";

                cmd.Parameters.AddWithValue("UID", UID);

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                AccessUserDetails Details = new AccessUserDetails();
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    Details.UID          = UID;
                    Details.UserName     = "" + dr["UserName"].ToString();
                    Details.Password     = "" + dr["Password"].ToString();
                    Details.DateCreated  = DateTime.Parse(dr["DateCreated"].ToString());
                    Details.Deleted      = bool.Parse(dr["Deleted"].ToString());
                    Details.Name         = "" + dr["Name"].ToString();
                    Details.Address1     = "" + dr["Address1"].ToString();
                    Details.Address2     = "" + dr["Address2"].ToString();
                    Details.City         = "" + dr["City"].ToString();
                    Details.State        = "" + dr["State"].ToString();
                    Details.CountryID    = Int32.Parse(dr["CountryID"].ToString());
                    Details.CountryName  = "" + dr["CountryName"].ToString();
                    Details.OfficePhone  = "" + dr["OfficePhone"].ToString();
                    Details.DirectPhone  = "" + dr["DirectPhone"].ToString();
                    Details.HomePhone    = "" + dr["HomePhone"].ToString();
                    Details.FaxPhone     = "" + dr["FaxPhone"].ToString();
                    Details.MobilePhone  = "" + dr["MobilePhone"].ToString();
                    Details.EmailAddress = "" + dr["EmailAddress"].ToString();
                    Details.GroupID      = Int32.Parse(dr["GroupID"].ToString());
                    Details.GroupName    = "" + dr["GroupName"].ToString();
                    Details.PageSize     = Int32.Parse(dr["PageSize"].ToString());
                    Details.CreatedOn    = DateTime.Parse(dr["CreatedOn"].ToString());
                    Details.LastModified = DateTime.Parse(dr["LastModified"].ToString());
                }

                return(Details);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Esempio n. 5
0
        public Int32 SaveDetails(AccessUserDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "CALL procSaveSysAccessUserDetails(@UID, @Name, @Address1, @Address2, @City, @State, @Zip, @CountryID," +
                             "@OfficePhone, @DirectPhone, @HomePhone, @FaxPhone, @MobilePhone, " +
                             "@EmailAddress, @GroupID, @PageSize, @CreatedOn, @LastModified);";


                cmd.Parameters.AddWithValue("UID", Details.UID);
                cmd.Parameters.AddWithValue("Name", Details.Name);
                cmd.Parameters.AddWithValue("Address1", Details.Address1);
                cmd.Parameters.AddWithValue("Address2", Details.Address2);
                cmd.Parameters.AddWithValue("City", Details.City);
                cmd.Parameters.AddWithValue("State", Details.State);
                cmd.Parameters.AddWithValue("Zip", Details.Zip);
                cmd.Parameters.AddWithValue("CountryID", Details.CountryID);
                cmd.Parameters.AddWithValue("OfficePhone", Details.OfficePhone);
                cmd.Parameters.AddWithValue("DirectPhone", Details.DirectPhone);
                cmd.Parameters.AddWithValue("HomePhone", Details.HomePhone);
                cmd.Parameters.AddWithValue("FaxPhone", Details.FaxPhone);
                cmd.Parameters.AddWithValue("MobilePhone", Details.MobilePhone);
                cmd.Parameters.AddWithValue("EmailAddress", Details.EmailAddress);
                cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                cmd.Parameters.AddWithValue("PageSize", Details.PageSize);
                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);

                cmd.CommandText = SQL;
                return(base.ExecuteNonQuery(cmd));
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Esempio n. 6
0
		public Int64 Insert(AccessUserDetails Details)
		{
			try 
			{
                Int64 iID = 0;

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

                string SQLUser = "******";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("UserName", Details.UserName);

                cmd.CommandText = SQLUser;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                if (dt.Rows.Count == 0)
                {
                    SQLUser = "******";
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("UserName", Details.UserName);
                    cmd.Parameters.AddWithValue("Password", Details.Password);
                    Details.DateCreated = DateTime.Now;
                    cmd.Parameters.AddWithValue("DateCreated", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));
                    cmd.Parameters.AddWithValue("CreatedOn", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));
                    cmd.Parameters.AddWithValue("LastModified", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));

                    cmd.CommandText = SQLUser;
                    base.ExecuteNonQuery(cmd);

                    iID = Int64.Parse(base.getLAST_INSERT_ID(this));
                }
                else
                {
                    iID = Int64.Parse(dt.Rows[0]["UID"].ToString());

                    SQLUser = "******";
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("UID", iID);
                    cmd.Parameters.AddWithValue("Password", Details.Password);

                    cmd.CommandText = SQLUser;
                    base.ExecuteNonQuery(cmd);
                }

                Details.UID = iID;

                SQLUser = "******";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("UID", iID);

                cmd.CommandText = SQLUser;
                base.MySqlDataAdapterFill(cmd, dt);

                if (dt.Rows.Count != 0)
                {
                    SQLUser = "******" +
                                            "Name			=	@Name, " +
                                            "Address1		=	@Address1, " +
                                            "Address2		=	@Address2, " +
                                            "City			=	@City, " +
                                            "State			=	@State, " +
                                            "CountryID		=	@CountryID, " +
                                            "OfficePhone	=	@OfficePhone, " +
                                            "DirectPhone	=	@DirectPhone, " +
                                            "HomePhone		=	@HomePhone, " +
                                            "FaxPhone		=	@FaxPhone, " +
                                            "MobilePhone	=	@MobilePhone, " +
                                            "EmailAddress	=	@EmailAddress, " +
                                            "GroupID		=	@GroupID, " +
                                            "PageSize		=	@PageSize " +
                                        "WHERE UID		=	@UID;";

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("Name", Details.Name);
                    cmd.Parameters.AddWithValue("Address1", Details.Address1);
                    cmd.Parameters.AddWithValue("Address2", Details.Address2);
                    cmd.Parameters.AddWithValue("City", Details.City);
                    cmd.Parameters.AddWithValue("State", Details.State);
                    cmd.Parameters.AddWithValue("CountryID", Details.CountryID);
                    cmd.Parameters.AddWithValue("OfficePhone", Details.OfficePhone);
                    cmd.Parameters.AddWithValue("DirectPhone", Details.DirectPhone);
                    cmd.Parameters.AddWithValue("HomePhone", Details.HomePhone);
                    cmd.Parameters.AddWithValue("FaxPhone", Details.FaxPhone);
                    cmd.Parameters.AddWithValue("MobilePhone", Details.MobilePhone);
                    cmd.Parameters.AddWithValue("EmailAddress", Details.EmailAddress);
                    cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                    if (Details.PageSize == 0) Details.PageSize = 10;
                    cmd.Parameters.AddWithValue("PageSize", Details.PageSize);
                    cmd.Parameters.AddWithValue("UID", Details.UID);

                    cmd.CommandText = SQLUser;
                    base.ExecuteNonQuery(cmd);
                }
                else
                {
                    cmd = new MySqlCommand();
                    cmd.CommandType = System.Data.CommandType.Text;

                    SQLUser = "******" +
                                            "UID," +
                                            "Name," +
                                            "Address1," +
                                            "Address2," +
                                            "City," +
                                            "State," +
                                            "CountryID," +
                                            "OfficePhone," +
                                            "DirectPhone," +
                                            "HomePhone," +
                                            "FaxPhone," +
                                            "MobilePhone," +
                                            "EmailAddress," +
                                            "GroupID, CreatedOn, LastModified) VALUES ( " +
                                            "@UID," +
                                            "@Name," +
                                            "@Address1," +
                                            "@Address2," +
                                            "@City," +
                                            "@State," +
                                            "@CountryID," +
                                            "@OfficePhone," +
                                            "@DirectPhone," +
                                            "@HomePhone," +
                                            "@FaxPhone," +
                                            "@MobilePhone," +
                                            "@EmailAddress," +
                                            "@GroupID, @CreatedOn, @LastModified);";

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("UID", iID);
                    cmd.Parameters.AddWithValue("Name", Details.Name);
                    cmd.Parameters.AddWithValue("Address1", Details.Address1);
                    cmd.Parameters.AddWithValue("Address2", Details.Address2);
                    cmd.Parameters.AddWithValue("City", Details.City);
                    cmd.Parameters.AddWithValue("State", Details.State);
                    cmd.Parameters.AddWithValue("CountryID", Details.CountryID);
                    cmd.Parameters.AddWithValue("OfficePhone", Details.OfficePhone);
                    cmd.Parameters.AddWithValue("DirectPhone", Details.DirectPhone);
                    cmd.Parameters.AddWithValue("HomePhone", Details.HomePhone);
                    cmd.Parameters.AddWithValue("FaxPhone", Details.FaxPhone);
                    cmd.Parameters.AddWithValue("MobilePhone", Details.MobilePhone);
                    cmd.Parameters.AddWithValue("EmailAddress", Details.EmailAddress);
                    cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                    cmd.Parameters.AddWithValue("CreatedOn", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));
                    cmd.Parameters.AddWithValue("LastModified", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));

                    cmd.CommandText = SQLUser;
                    base.ExecuteNonQuery(cmd);
                }

				InsertAccessRights(iID, Details.GroupID);

				return iID;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Esempio n. 7
0
		public AccessUserDetails Details(Int64 UID)
		{
			try
			{
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

				string SQL = SQLSelect() + "WHERE a.UID = @UID;";

                cmd.Parameters.AddWithValue("UID", UID);

				cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                AccessUserDetails Details = new AccessUserDetails();
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    Details.UID = UID;
                    Details.UserName = "" + dr["UserName"].ToString();
                    Details.Password = "" + dr["Password"].ToString();
                    Details.DateCreated = DateTime.Parse(dr["DateCreated"].ToString());
                    Details.Deleted = bool.Parse(dr["Deleted"].ToString());
                    Details.Name = "" + dr["Name"].ToString();
                    Details.Address1 = "" + dr["Address1"].ToString();
                    Details.Address2 = "" + dr["Address2"].ToString();
                    Details.City = "" + dr["City"].ToString();
                    Details.State = "" + dr["State"].ToString();
                    Details.CountryID = Int32.Parse(dr["CountryID"].ToString());
                    Details.CountryName = "" + dr["CountryName"].ToString();
                    Details.OfficePhone = "" + dr["OfficePhone"].ToString();
                    Details.DirectPhone = "" + dr["DirectPhone"].ToString();
                    Details.HomePhone = "" + dr["HomePhone"].ToString();
                    Details.FaxPhone = "" + dr["FaxPhone"].ToString();
                    Details.MobilePhone = "" + dr["MobilePhone"].ToString();
                    Details.EmailAddress = "" + dr["EmailAddress"].ToString();
                    Details.GroupID = Int32.Parse(dr["GroupID"].ToString());
                    Details.GroupName = "" + dr["GroupName"].ToString();
                    Details.PageSize = Int32.Parse(dr["PageSize"].ToString());
                    Details.CreatedOn = DateTime.Parse(dr["CreatedOn"].ToString());
                    Details.LastModified = DateTime.Parse(dr["LastModified"].ToString());
                }

				return Details;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Esempio n. 8
0
        public Int32 SaveDetails(AccessUserDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "CALL procSaveSysAccessUserDetails(@UID, @Name, @Address1, @Address2, @City, @State, @Zip, @CountryID," + 
                                                               "@OfficePhone, @DirectPhone, @HomePhone, @FaxPhone, @MobilePhone, " +
										                       "@EmailAddress, @GroupID, @PageSize, @CreatedOn, @LastModified);";

                
                cmd.Parameters.AddWithValue("UID", Details.UID);
                cmd.Parameters.AddWithValue("Name", Details.Name);
                cmd.Parameters.AddWithValue("Address1", Details.Address1);
                cmd.Parameters.AddWithValue("Address2", Details.Address2);
                cmd.Parameters.AddWithValue("City", Details.City);
                cmd.Parameters.AddWithValue("State", Details.State);
                cmd.Parameters.AddWithValue("Zip", Details.Zip);
                cmd.Parameters.AddWithValue("CountryID", Details.CountryID);
                cmd.Parameters.AddWithValue("OfficePhone", Details.OfficePhone);
                cmd.Parameters.AddWithValue("DirectPhone", Details.DirectPhone);
                cmd.Parameters.AddWithValue("HomePhone", Details.HomePhone);
                cmd.Parameters.AddWithValue("FaxPhone", Details.FaxPhone);
                cmd.Parameters.AddWithValue("MobilePhone", Details.MobilePhone);
                cmd.Parameters.AddWithValue("EmailAddress", Details.EmailAddress);
                cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                cmd.Parameters.AddWithValue("PageSize", Details.PageSize);
                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);

                cmd.CommandText = SQL;
                return base.ExecuteNonQuery(cmd);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Esempio n. 9
0
        public Int32 Save(AccessUserDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "CALL procSaveSysAccessUsers(@UID, @UserName, @Password, @DateCreated, @Deleted, @CreatedOn, @LastModified);";

                cmd.Parameters.AddWithValue("UID", Details.UID);
                cmd.Parameters.AddWithValue("UserName", Details.UserName);
                cmd.Parameters.AddWithValue("Password", Details.Password);
                cmd.Parameters.AddWithValue("DateCreated", Details.DateCreated);
                cmd.Parameters.AddWithValue("Deleted", Details.Deleted);
                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);

                cmd.CommandText = SQL;
                return base.ExecuteNonQuery(cmd);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Esempio n. 10
0
		public void Update(AccessUserDetails Details)
		{
			try 
			{
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQLUser = "";
                if (!string.IsNullOrEmpty(Details.Password))
                {
                    SQLUser = "******" +
                                                "UserName = @UserName, " +
                                                "Password = @Password " +
                                            "WHERE UID = @UID;";

                    cmd.Parameters.AddWithValue("Password", Details.Password);
                    cmd.Parameters.AddWithValue("UserName", Details.UserName);
                    cmd.Parameters.AddWithValue("UID", Details.UID);
                }
                else
                {
                    SQLUser = "******" +
                                            "UserName = @UserName " +
                                        "WHERE UID = @UID;";

                    cmd.Parameters.AddWithValue("UserName", Details.UserName);
                    cmd.Parameters.AddWithValue("UID", Details.UID);
                }
                

                cmd.CommandText = SQLUser;
                base.ExecuteNonQuery(cmd);

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

                string SQLDetails = "UPDATE sysAccessUserDetails SET " +
                                            "Name			=	@Name, " +
                                            "Address1		=	@Address1, " +
                                            "Address2		=	@Address2, " +
                                            "City			=	@City, " +
                                            "State			=	@State, " +
                                            "CountryID		=	@CountryID, " +
                                            "OfficePhone	=	@OfficePhone, " +
                                            "DirectPhone	=	@DirectPhone, " +
                                            "HomePhone		=	@HomePhone, " +
                                            "FaxPhone		=	@FaxPhone, " +
                                            "MobilePhone	=	@MobilePhone, " +
                                            "EmailAddress	=	@EmailAddress, " +
                                            "GroupID		=	@GroupID, " +
                                            "PageSize		=	@PageSize " +
                                        "WHERE UID		=	@UID;";
                
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("Name", Details.Name);
                cmd.Parameters.AddWithValue("Address1", Details.Address1);
                cmd.Parameters.AddWithValue("Address2", Details.Address2);
                cmd.Parameters.AddWithValue("City", Details.City);
                cmd.Parameters.AddWithValue("State", Details.State);
                cmd.Parameters.AddWithValue("CountryID", Details.CountryID);
                cmd.Parameters.AddWithValue("OfficePhone", Details.OfficePhone);
                cmd.Parameters.AddWithValue("DirectPhone", Details.DirectPhone);
                cmd.Parameters.AddWithValue("HomePhone", Details.HomePhone);
                cmd.Parameters.AddWithValue("FaxPhone", Details.FaxPhone);
                cmd.Parameters.AddWithValue("MobilePhone", Details.MobilePhone);
                cmd.Parameters.AddWithValue("EmailAddress", Details.EmailAddress);
                cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                if (Details.PageSize == 0) Details.PageSize = 10;
                cmd.Parameters.AddWithValue("PageSize", Details.PageSize);
                cmd.Parameters.AddWithValue("UID", Details.UID);

                cmd.CommandText = SQLDetails;
                base.ExecuteNonQuery(cmd);

                InsertAccessRights(Details.UID, Details.GroupID);
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Esempio n. 11
0
        public Int64 Insert(AccessUserDetails Details)
        {
            try
            {
                Int64 iID = 0;

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

                string SQLUser = "******";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("UserName", Details.UserName);

                cmd.CommandText = SQLUser;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                if (dt.Rows.Count == 0)
                {
                    SQLUser = "******";
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("UserName", Details.UserName);
                    cmd.Parameters.AddWithValue("Password", Details.Password);
                    Details.DateCreated = DateTime.Now;
                    cmd.Parameters.AddWithValue("DateCreated", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));
                    cmd.Parameters.AddWithValue("CreatedOn", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));
                    cmd.Parameters.AddWithValue("LastModified", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));

                    cmd.CommandText = SQLUser;
                    base.ExecuteNonQuery(cmd);

                    iID = Int64.Parse(base.getLAST_INSERT_ID(this));
                }
                else
                {
                    iID = Int64.Parse(dt.Rows[0]["UID"].ToString());

                    SQLUser = "******";
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("UID", iID);
                    cmd.Parameters.AddWithValue("Password", Details.Password);

                    cmd.CommandText = SQLUser;
                    base.ExecuteNonQuery(cmd);
                }

                Details.UID = iID;

                SQLUser = "******";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("UID", iID);

                cmd.CommandText = SQLUser;
                base.MySqlDataAdapterFill(cmd, dt);

                if (dt.Rows.Count != 0)
                {
                    SQLUser = "******" +
                              "Name			=	@Name, "+
                              "Address1		=	@Address1, "+
                              "Address2		=	@Address2, "+
                              "City			=	@City, "+
                              "State			=	@State, "+
                              "CountryID		=	@CountryID, "+
                              "OfficePhone	=	@OfficePhone, "+
                              "DirectPhone	=	@DirectPhone, "+
                              "HomePhone		=	@HomePhone, "+
                              "FaxPhone		=	@FaxPhone, "+
                              "MobilePhone	=	@MobilePhone, "+
                              "EmailAddress	=	@EmailAddress, "+
                              "GroupID		=	@GroupID, "+
                              "PageSize		=	@PageSize "+
                              "WHERE UID		=	@UID;";

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("Name", Details.Name);
                    cmd.Parameters.AddWithValue("Address1", Details.Address1);
                    cmd.Parameters.AddWithValue("Address2", Details.Address2);
                    cmd.Parameters.AddWithValue("City", Details.City);
                    cmd.Parameters.AddWithValue("State", Details.State);
                    cmd.Parameters.AddWithValue("CountryID", Details.CountryID);
                    cmd.Parameters.AddWithValue("OfficePhone", Details.OfficePhone);
                    cmd.Parameters.AddWithValue("DirectPhone", Details.DirectPhone);
                    cmd.Parameters.AddWithValue("HomePhone", Details.HomePhone);
                    cmd.Parameters.AddWithValue("FaxPhone", Details.FaxPhone);
                    cmd.Parameters.AddWithValue("MobilePhone", Details.MobilePhone);
                    cmd.Parameters.AddWithValue("EmailAddress", Details.EmailAddress);
                    cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                    if (Details.PageSize == 0)
                    {
                        Details.PageSize = 10;
                    }
                    cmd.Parameters.AddWithValue("PageSize", Details.PageSize);
                    cmd.Parameters.AddWithValue("UID", Details.UID);

                    cmd.CommandText = SQLUser;
                    base.ExecuteNonQuery(cmd);
                }
                else
                {
                    cmd             = new MySqlCommand();
                    cmd.CommandType = System.Data.CommandType.Text;

                    SQLUser = "******" +
                              "UID," +
                              "Name," +
                              "Address1," +
                              "Address2," +
                              "City," +
                              "State," +
                              "CountryID," +
                              "OfficePhone," +
                              "DirectPhone," +
                              "HomePhone," +
                              "FaxPhone," +
                              "MobilePhone," +
                              "EmailAddress," +
                              "GroupID, CreatedOn, LastModified) VALUES ( " +
                              "@UID," +
                              "@Name," +
                              "@Address1," +
                              "@Address2," +
                              "@City," +
                              "@State," +
                              "@CountryID," +
                              "@OfficePhone," +
                              "@DirectPhone," +
                              "@HomePhone," +
                              "@FaxPhone," +
                              "@MobilePhone," +
                              "@EmailAddress," +
                              "@GroupID, @CreatedOn, @LastModified);";

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("UID", iID);
                    cmd.Parameters.AddWithValue("Name", Details.Name);
                    cmd.Parameters.AddWithValue("Address1", Details.Address1);
                    cmd.Parameters.AddWithValue("Address2", Details.Address2);
                    cmd.Parameters.AddWithValue("City", Details.City);
                    cmd.Parameters.AddWithValue("State", Details.State);
                    cmd.Parameters.AddWithValue("CountryID", Details.CountryID);
                    cmd.Parameters.AddWithValue("OfficePhone", Details.OfficePhone);
                    cmd.Parameters.AddWithValue("DirectPhone", Details.DirectPhone);
                    cmd.Parameters.AddWithValue("HomePhone", Details.HomePhone);
                    cmd.Parameters.AddWithValue("FaxPhone", Details.FaxPhone);
                    cmd.Parameters.AddWithValue("MobilePhone", Details.MobilePhone);
                    cmd.Parameters.AddWithValue("EmailAddress", Details.EmailAddress);
                    cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                    cmd.Parameters.AddWithValue("CreatedOn", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));
                    cmd.Parameters.AddWithValue("LastModified", Details.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"));

                    cmd.CommandText = SQLUser;
                    base.ExecuteNonQuery(cmd);
                }

                InsertAccessRights(iID, Details.GroupID);

                return(iID);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Esempio n. 12
0
        public void Update(AccessUserDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQLUser = "";
                if (!string.IsNullOrEmpty(Details.Password))
                {
                    SQLUser = "******" +
                              "UserName = @UserName, " +
                              "Password = @Password " +
                              "WHERE UID = @UID;";

                    cmd.Parameters.AddWithValue("Password", Details.Password);
                    cmd.Parameters.AddWithValue("UserName", Details.UserName);
                    cmd.Parameters.AddWithValue("UID", Details.UID);
                }
                else
                {
                    SQLUser = "******" +
                              "UserName = @UserName " +
                              "WHERE UID = @UID;";

                    cmd.Parameters.AddWithValue("UserName", Details.UserName);
                    cmd.Parameters.AddWithValue("UID", Details.UID);
                }


                cmd.CommandText = SQLUser;
                base.ExecuteNonQuery(cmd);

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

                string SQLDetails = "UPDATE sysAccessUserDetails SET " +
                                    "Name			=	@Name, "+
                                    "Address1		=	@Address1, "+
                                    "Address2		=	@Address2, "+
                                    "City			=	@City, "+
                                    "State			=	@State, "+
                                    "CountryID		=	@CountryID, "+
                                    "OfficePhone	=	@OfficePhone, "+
                                    "DirectPhone	=	@DirectPhone, "+
                                    "HomePhone		=	@HomePhone, "+
                                    "FaxPhone		=	@FaxPhone, "+
                                    "MobilePhone	=	@MobilePhone, "+
                                    "EmailAddress	=	@EmailAddress, "+
                                    "GroupID		=	@GroupID, "+
                                    "PageSize		=	@PageSize "+
                                    "WHERE UID		=	@UID;";

                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("Name", Details.Name);
                cmd.Parameters.AddWithValue("Address1", Details.Address1);
                cmd.Parameters.AddWithValue("Address2", Details.Address2);
                cmd.Parameters.AddWithValue("City", Details.City);
                cmd.Parameters.AddWithValue("State", Details.State);
                cmd.Parameters.AddWithValue("CountryID", Details.CountryID);
                cmd.Parameters.AddWithValue("OfficePhone", Details.OfficePhone);
                cmd.Parameters.AddWithValue("DirectPhone", Details.DirectPhone);
                cmd.Parameters.AddWithValue("HomePhone", Details.HomePhone);
                cmd.Parameters.AddWithValue("FaxPhone", Details.FaxPhone);
                cmd.Parameters.AddWithValue("MobilePhone", Details.MobilePhone);
                cmd.Parameters.AddWithValue("EmailAddress", Details.EmailAddress);
                cmd.Parameters.AddWithValue("GroupID", Details.GroupID);
                if (Details.PageSize == 0)
                {
                    Details.PageSize = 10;
                }
                cmd.Parameters.AddWithValue("PageSize", Details.PageSize);
                cmd.Parameters.AddWithValue("UID", Details.UID);

                cmd.CommandText = SQLDetails;
                base.ExecuteNonQuery(cmd);

                InsertAccessRights(Details.UID, Details.GroupID);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Esempio n. 13
0
		private void SaveRecord()
		{
			AccessUser clsAccessUser = new AccessUser();
			AccessUserDetails clsDetails = new AccessUserDetails();

			clsDetails.UID = Convert.ToInt64(lblUID.Text);
			clsDetails.UserName  = txtUserName.Text;
			clsDetails.Password  = txtPassword.Text;
			clsDetails.Name = txtName.Text;
			clsDetails.CountryID = Convert.ToInt32(cboCountry.SelectedItem.Value); 
			clsDetails.Address1  = txtAddress1.Text;
			clsDetails.Address2  = txtAddress2.Text;
			clsDetails.City  = txtCity.Text;
			clsDetails.State = txtState.Text;
			clsDetails.OfficePhone = txtOfficePhone.Text;
			clsDetails.DirectPhone = txtDirectPhone.Text;
			clsDetails.HomePhone = txtHomePhone.Text;
			clsDetails.FaxPhone = txtFaxNumber.Text;
			clsDetails.MobilePhone = txtMobile.Text;
			clsDetails.EmailAddress = txtEmail.Text;
			clsDetails.GroupID = Convert.ToInt32(cboGroup.SelectedItem.Value);
			clsDetails.PageSize = Convert.ToInt32(txtPageSize.Text);

			clsAccessUser.Update(clsDetails);
			clsAccessUser.CommitAndDispose();

			AssignUserSession(clsDetails);
		}
Esempio n. 14
0
		private void AssignUserSession(AccessUserDetails clsDetails)
		{
            Session["AccessUserDetails"] = clsDetails;

//			Session.RemoveAll();
			Session.Add("PageSize",clsDetails.PageSize);
			Session.Add("UID", clsDetails.UID);
			Session.Add("UserName", clsDetails.UserName);
			Session.Add("Password", clsDetails.Password);
			Session.Add("Name",clsDetails.Name);

			Session.Add("CountryID", clsDetails.CountryID);

			Session.Add("Addres1", clsDetails.Address1);
			Session.Add("Addres2", clsDetails.Address2);
			Session.Add("City", clsDetails.City);
			Session.Add("State", clsDetails.State);
			Session.Add("OfficePhone", clsDetails.OfficePhone);
			Session.Add("DirectPhone", clsDetails.DirectPhone);
			Session.Add("HomePhone", clsDetails.HomePhone);
			Session.Add("FaxPhone", clsDetails.FaxPhone);
			Session.Add("MobilePhone", clsDetails.MobilePhone);
			Session.Add("EmailAddress", clsDetails.EmailAddress);
		}