Ejemplo n.º 1
0
        private void AssignValue()
        {
            newUser = new clsUserDetailsModel()
            {
                sUsername        = txtEmail.Text.Trim(),
                sPassword        = txtPassword.Text.Trim(),
                sReEnterPassword = txtReEnterPassword.Text.Trim(),
                eUserType        = GetUserType(Convert.ToInt32(drpRole.SelectedValue)),
                bStatus          = true,

                sName      = txtName.Text.Trim(),
                sSurname   = txtSurname.Text.Trim(),
                sAddress   = txtAddress.Text.Trim(),
                iCountryId = Convert.ToInt32(drpCountry.SelectedValue),

                sEmail   = txtEmailDetail.Text.Trim(),
                sFixLine = txtPhoneFix.Text.Trim(),
                sMobile  = txtPhoneMobile.Text.Trim(),
                sFax     = txtFax.Text.Trim(),

                sCompany = txtCompany.Text.Trim(),
                sBRN     = txtBRN.Text.Trim(),
                sNote    = txtNote.Text.Trim(),
            };
        }
Ejemplo n.º 2
0
        private void UpdateUser(clsUserDetailsModel item)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new Exception();
            }

            connection = new SqlConnection(connectionString);
            connection.Open();
            if (connection == null)
            {
                throw new Exception();
            }

            SqlCommand command = new SqlCommand("tblUserupdate", connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            command.Parameters.Add(new SqlParameter("@userId", item.iUserId));
            command.Parameters.Add(new SqlParameter("@email", item.sUsername));
            command.Parameters.Add(new SqlParameter("@password", item.sPassword));

            command.ExecuteNonQuery();
        }
Ejemplo n.º 3
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                model = new clsUserDetailsModel();
                model = businessLayer.Login(txtEmail.Text.Trim(), txtPassword.Text.Trim(), UserType.AdminStaff);

                if (model == null || model.iUserId == 0)
                {
                    throw new FormatException("Invalid username and password");
                }

                Session["Customer"] = model;
                Response.Redirect("~/WebForms/Sale/Sales.aspx", false);
            }
            catch (FormatException ex)
            {
                pnlError.Visible = true;
                lblError.Text    = ex.Message;
            }
            catch (Exception ex)
            {
                Response.Redirect(string.Format("Error.aspx?stat={0}", (int)ErrorStatus.LoginFail));
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = businessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (!IsPostBack)
                {
                    Navigate(OrderType.Pending);
                    LoadOrders(OrderType.Pending);
                }
            }
            catch (Exception ex)
            {
                Response.Redirect(string.Format("~/Error.aspx?stat={0}", (int)ErrorStatus.InvalidSession), false);
            }
        }
Ejemplo n.º 5
0
        public clsUserDetailsModel SignUp(clsUserDetailsModel item)
        {
            clsUserDetailsModel result = new clsUserDetailsModel();
            DataSet             data   = new DataSet();

            if (IsSignUpModelValid(item))
            {
                data = dataLayer.SignUp(item);

                if (data?.Tables.Count == 0)
                {
                    throw new Exception();
                }

                if (data?.Tables[0].Rows.Count == 0 || data?.Tables[1].Rows.Count == 0)
                {
                    throw new Exception();
                }

                result = new clsUserDetailsModel()
                {
                    iUserId        = Convert.ToInt32(data?.Tables[0].Rows[0][0]),
                    iUserDetailsId = Convert.ToInt32(data?.Tables[1].Rows[0][0]),
                };
            }

            return(result);
        }
Ejemplo n.º 6
0
 public void Setting(clsUserDetailsModel item)
 {
     if (IsSignUpModelValid(item))
     {
         dataLayer.Setting(item);
     }
 }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = BusinessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (userDetails.eUserType != UserType.Admin)
                {
                    lkAddUser.Visible = false;
                }

                if (!IsPostBack)
                {
                }
            }
            catch (Exception)
            {
                Response.Redirect(string.Format("~/Error.aspx?stat={0}", (int)ErrorStatus.InvalidSession));
            }
        }
Ejemplo n.º 8
0
        protected void btnSuspend_Click(object sender, EventArgs e)
        {
            try
            {
                clsUserDetailsModel  seletedUserDetails = new clsUserDetailsModel();
                List <clsOrderModel> customerOrders     = new List <clsOrderModel>();
                bool      newStatus;
                OrderType newOrderType;

                pnlError.Visible      = false;
                selectedUserDetailsId = grdCustomer.SelectedRow == null ? 0 : Convert.ToInt32(grdCustomer.SelectedRow.Cells[0].Text);

                if (selectedUserDetailsId == 0)
                {
                    throw new Exception();
                }

                seletedUserDetails = BusinessLayer.GetUserByUserDetailId(selectedUserDetailsId);

                if (seletedUserDetails.bStatus)
                {
                    newStatus    = false;
                    newOrderType = OrderType.Hold;
                }
                else
                {
                    newStatus    = true;
                    newOrderType = OrderType.Pending;
                }

                foreach (OrderType item in (OrderType[])Enum.GetValues(typeof(OrderType)))
                {
                    var orderLoop = item;

                    List <clsOrderModel> orders = new List <clsOrderModel>();
                    orders = BusinessLayer.ViewOrder(false, selectedUserDetailsId, orderLoop);
                    if (orders.Count > 0)
                    {
                        foreach (var orderItem in orders)
                        {
                            customerOrders.Add(orderItem);
                        }
                    }
                }

                seletedUserDetails.bStatus = newStatus;
                BusinessLayer.Setting(seletedUserDetails);

                foreach (var item in customerOrders)
                {
                    BusinessLayer.UpdateOrderStatus(item.iOrderId, newOrderType);
                }

                RetrieveAndBindCustomer();
            }
            catch (Exception)
            {
                pnlError.Visible = true;
            }
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = businessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (!IsPostBack)
                {
                    List <clsMeasurementUnitModel> measurementUnit = new List <clsMeasurementUnitModel>();
                    List <clsUserDetailsModel>     suppliers       = new List <clsUserDetailsModel>();
                    measurementUnit = master.RetrieveMeasurement();
                    suppliers       = businessLayer.RetrieveUser(UserType.Supplier);

                    foreach (var item in measurementUnit)
                    {
                        ListItem list = new ListItem(item.sMeasurement, item.iMeasurementId.ToString(), true);
                        drpMeasureUnit.Items.Add(list);
                    }

                    foreach (var item in suppliers)
                    {
                        ListItem list = new ListItem(string.Format("{0} - {1} {2}", item.sCompany, item.sName, item.sSurname), item.iUserDetailsId.ToString(), true);
                        drpSuppliers.Items.Add(list);
                    }

                    drpMeasureUnit.SelectedValue = 1.ToString();
                    drpSuppliers.SelectedIndex   = 1;
                }
            }
            catch (Exception ex)
            {
                switch (Convert.ToInt32(ex.Message))
                {
                case (int)ErrorStatus.LoadCountryMasterDataFail:
                    Response.Redirect(string.Format("~/Error.aspx?stat={0}", (int)ErrorStatus.LoginFail));
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = businessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                supplierId = Request.QueryString["suppid"] == null ? 0 : Convert.ToInt32(Request.QueryString["suppid"]);

                if (!IsPostBack)
                {
                    List <clsCountryModel> countries = new List <clsCountryModel>();
                    countries = master.RetrieveCountry();

                    foreach (var item in countries)
                    {
                        ListItem list = new ListItem(item.sCountryName, item.iCountryId.ToString(), true);
                        drpCountry.Items.Add(list);
                    }

                    drpCountry.SelectedIndex = 0;

                    if (supplierId != 0)
                    {
                        btnAdd.Text = "Update";
                        RetrieveSupplier();
                    }
                }
            }
            catch (Exception ex)
            {
                switch (Convert.ToInt32(ex.Message))
                {
                case (int)ErrorStatus.LoadCountryMasterDataFail:
                    Response.Redirect(string.Format("~/Error.aspx?stat={0}", (int)ErrorStatus.LoginFail));
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 11
0
        private void RetrieveSupplier()
        {
            clsUserDetailsModel supplier = new clsUserDetailsModel();

            if (supplierId > 0)
            {
                supplier = businessLayer.GetUserByUserDetailId(supplierId);
            }

            AssignValue(supplier);
        }
Ejemplo n.º 12
0
        private DataTable SaveUserDetails(clsUserDetailsModel item)
        {
            DataTable result = new DataTable();

            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new Exception();
            }

            connection = new SqlConnection(connectionString);
            connection.Open();
            if (connection == null)
            {
                throw new Exception();
            }

            SqlCommand command = new SqlCommand("tblUserDetailsSave", connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            command.Parameters.Add(new SqlParameter("@userId", item.iUserId));
            command.Parameters.Add(new SqlParameter("@userTypeId", (int)item.eUserType));
            command.Parameters.Add(new SqlParameter("@status", item.bStatus));

            command.Parameters.Add(new SqlParameter("@name", item.sName));
            command.Parameters.Add(new SqlParameter("@surnmae", item.sSurname));
            command.Parameters.Add(new SqlParameter("@address", item.sAddress));
            command.Parameters.Add(new SqlParameter("@countryId", item.iCountryId));

            command.Parameters.Add(new SqlParameter("@email", item.sEmail));
            command.Parameters.Add(new SqlParameter("@fix", item.sFixLine));
            command.Parameters.Add(new SqlParameter("@mobile", item.sMobile));
            command.Parameters.Add(new SqlParameter("@web", item.sWebsite));
            command.Parameters.Add(new SqlParameter("@fax", item.sFax));

            command.Parameters.Add(new SqlParameter("@company", item.sCompany));
            command.Parameters.Add(new SqlParameter("@brn", item.sBRN));
            command.Parameters.Add(new SqlParameter("@note", item.sNote));

            result.Load(command.ExecuteReader());
            if (result?.Rows.Count == 0)
            {
                throw new Exception();
            }

            if (connection != null)
            {
                connection.Close();
            }

            return(result);
        }
Ejemplo n.º 13
0
        private void AssignValue(clsUserDetailsModel supplier)
        {
            txtName.Text             = supplier.sName;
            txtSurname.Text          = supplier.sSurname;
            txtAddress.Text          = supplier.sAddress;
            drpCountry.SelectedValue = supplier.iCountryId.ToString();

            txtEmailDetail.Text = supplier.sEmail;
            txtPhoneFix.Text    = supplier.sFixLine;
            txtPhoneMobile.Text = supplier.sMobile;
            txtFax.Text         = supplier.sFax;

            txtCompany.Text = supplier.sCompany;
            txtBRN.Text     = supplier.sBRN;
            txtNote.Text    = supplier.sNote;
        }
Ejemplo n.º 14
0
        private void UpdateUserDetails(clsUserDetailsModel item)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new Exception();
            }

            connection = new SqlConnection(connectionString);
            connection.Open();
            if (connection == null)
            {
                throw new Exception();
            }

            SqlCommand command = new SqlCommand("tblUserDetailsUpdate", connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            command.Parameters.Add(new SqlParameter("@userDetailsId", item.iUserDetailsId));
            command.Parameters.Add(new SqlParameter("@userId", item.iUserId));
            command.Parameters.Add(new SqlParameter("@userTypeId", (int)item.eUserType));
            command.Parameters.Add(new SqlParameter("@status", item.bStatus));

            command.Parameters.Add(new SqlParameter("@name", item.sName));
            command.Parameters.Add(new SqlParameter("@surnmae", item.sSurname));
            command.Parameters.Add(new SqlParameter("@address", item.sAddress));
            command.Parameters.Add(new SqlParameter("@countryId", item.iCountryId));

            command.Parameters.Add(new SqlParameter("@email", item.sEmail));
            command.Parameters.Add(new SqlParameter("@fix", item.sFixLine));
            command.Parameters.Add(new SqlParameter("@mobile", item.sMobile));

            command.Parameters.Add(new SqlParameter("@company", item.sCompany));
            command.Parameters.Add(new SqlParameter("@brn", item.sBRN));
            command.Parameters.Add(new SqlParameter("@note", item.sNote));

            command.Parameters.Add(new SqlParameter("@web", item.sWebsite));
            command.Parameters.Add(new SqlParameter("@fax", item.sFax));

            command.ExecuteNonQuery();

            if (connection != null)
            {
                connection.Close();
            }
        }
Ejemplo n.º 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = businessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (!IsPostBack)
                {
                    LoadOrders();
                    orderId = Request.QueryString["orderid"] == null?Convert.ToInt32(drpOrders.SelectedValue) : Convert.ToInt32(Request.QueryString["orderid"]);

                    drpOrders.SelectedValue = orderId.ToString();
                }

                if (orderId == 0)
                {
                    orderId = Convert.ToInt32(drpOrders.SelectedValue);
                }

                var selectedOrder = LoadOrdersByOrderId(orderId);
                if (selectedOrder != null || selectedOrder.iOrderId != 0)
                {
                    AssignValue(selectedOrder);
                }

                AddControlAttribute();
            }
            catch (Exception)
            {
                Response.Redirect(string.Format("~/Error.aspx?stat={0}", (int)ErrorStatus.InvalidSession));
            }
        }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = BusinessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (!IsPostBack)
                {
                    List <clsFruitModel> fruits = new List <clsFruitModel>();
                    fruits = master.RetrieveFruits();

                    foreach (var item in fruits)
                    {
                        ListItem list = new ListItem(item.sFruitName, item.iFruitId.ToString(), true);
                        drpFruit.Items.Add(list);
                    }

                    drpFruit.SelectedIndex = 0;
                }

                LoadFruitByFruitId(Convert.ToInt32(drpFruit.SelectedValue));
                AddControlAttribute();
            }
            catch (Exception)
            {
                Response.Redirect(string.Format("Error.aspx?stat={0}", (int)ErrorStatus.InvalidSession));
            }
        }
Ejemplo n.º 17
0
        public DataSet SignUp(clsUserDetailsModel item)
        {
            DataSet   result          = new DataSet();
            DataTable userData        = new DataTable();
            DataTable userDetailsData = new DataTable();

            userData = SaveUserData(item);
            if (userData.Rows.Count == 0)
            {
                throw new Exception();
            }

            item.iUserId    = Convert.ToInt32(userData.Rows[0][0]);
            userDetailsData = SaveUserDetails(item);

            result.Tables.Add(userData);
            result.Tables.Add(userDetailsData);

            return(result);
        }
Ejemplo n.º 18
0
        private bool IsSignUpModelValid(clsUserDetailsModel item)
        {
            bool result = true;

            if (string.IsNullOrWhiteSpace(item.sUsername))
            {
                throw new FormatException(Convert.ToString((int)ErrorStatus.SignupUsernameMissing));
            }

            if (string.IsNullOrWhiteSpace(item.sPassword))
            {
                throw new FormatException(Convert.ToString((int)ErrorStatus.SigupPasswordMissing));
            }

            if (string.IsNullOrWhiteSpace(item.sReEnterPassword))
            {
                throw new FormatException(Convert.ToString((int)ErrorStatus.SignupRePasswordMissing));
            }

            if (item.sPassword != item.sReEnterPassword)
            {
                throw new FormatException(Convert.ToString((int)ErrorStatus.SignupPasswordNotMatch));
            }

            if (string.IsNullOrWhiteSpace(item.sName))
            {
                throw new FormatException(Convert.ToString((int)ErrorStatus.SignupNameMissing));
            }

            if (string.IsNullOrWhiteSpace(item.sSurname))
            {
                throw new FormatException(Convert.ToString((int)ErrorStatus.SignupSurnameMissing));
            }

            if (string.IsNullOrWhiteSpace(item.sCompany))
            {
                throw new FormatException(Convert.ToString((int)ErrorStatus.SignupCompanyMissing));
            }

            return(result);
        }
Ejemplo n.º 19
0
        public clsUserDetailsModel GetUserByUserDetailId(int userDetailsId)
        {
            clsUserDetailsModel result = new clsUserDetailsModel();
            DataSet             data   = new DataSet();

            if (userDetailsId == 0)
            {
                throw new Exception();
            }

            data = dataLayer.GetUserByUserDetailId(userDetailsId);
            if (data?.Tables.Count == 0 || data?.Tables[0]?.Rows.Count == 0)
            {
                throw new Exception();
            }

            result = new clsUserDetailsModel()
            {
                iUserId          = Convert.ToInt32(data.Tables[0].Rows[0][0]),
                sUsername        = data.Tables[0].Rows[0][1].ToString(),
                sPassword        = data.Tables[0].Rows[0][2].ToString(),
                sReEnterPassword = data.Tables[0].Rows[0][2].ToString(),
                iUserDetailsId   = userDetailsId,
                eUserType        = GetUserType(Convert.ToInt32(data.Tables[0].Rows[0][5].ToString())),
                sName            = data.Tables[0].Rows[0][6].ToString(),
                sSurname         = data.Tables[0].Rows[0][7].ToString(),
                sAddress         = data.Tables[0].Rows[0][8].ToString(),
                sEmail           = data.Tables[0].Rows[0][9].ToString(),
                sFixLine         = data.Tables[0].Rows[0][10].ToString(),
                sWebsite         = data.Tables[0].Rows[0][11].ToString(),
                sNote            = data.Tables[0].Rows[0][12].ToString(),
                sCompany         = data.Tables[0].Rows[0][13].ToString(),
                sBRN             = data.Tables[0].Rows[0][14].ToString(),
                iCountryId       = Convert.ToInt32(data.Tables[0].Rows[0][15].ToString()),
                sMobile          = data.Tables[0].Rows[0][16].ToString(),
                bStatus          = Convert.ToBoolean(data.Tables[0].Rows[0][17].ToString()),
                sFax             = data.Tables[0].Rows[0][18].ToString(),
            };

            return(result);
        }
Ejemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = BusinessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (!IsPostBack)
                {
                    List <clsCountryModel> countries = new List <clsCountryModel>();
                    countries = master.RetrieveCountry();

                    foreach (var item in countries)
                    {
                        ListItem list = new ListItem(item.sCountryName, item.iCountryId.ToString(), true);
                        drpCountry.Items.Add(list);
                    }

                    AssignValue(false);
                }
            }
            catch (Exception)
            {
                Response.Redirect(string.Format("Error.aspx?stat={0}", (int)ErrorStatus.InvalidSession));
            }
        }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = businessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (!IsPostBack)
                {
                    RetriveFruit();
                }
            }
            catch (Exception ex)
            {
                switch (Convert.ToInt32(ex.Message))
                {
                case (int)ErrorStatus.LoadCountryMasterDataFail:
                    Response.Redirect(string.Format("~/Error.aspx?stat={0}", (int)ErrorStatus.LoginFail));
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 22
0
        public clsUserDetailsModel Login(string email, string password, UserType userType)
        {
            clsUserDetailsModel result  = null;
            DataSet             dataSet = new DataSet();

            if (IsLoginModelValid(email, password))
            {
                dataSet = dataLayer.Login(email, password, userType);

                if (dataSet?.Tables?.Count == 0 || dataSet?.Tables[0]?.Rows?.Count == 0)
                {
                    throw new FormatException("Invalid username and password");
                }

                result = new clsUserDetailsModel()
                {
                    iUserId        = Convert.ToInt32(dataSet.Tables[0].Rows[0][0]),
                    iUserDetailsId = Convert.ToInt32(dataSet.Tables[0].Rows[0][1])
                };
            }
            return(result);
        }
Ejemplo n.º 23
0
        private DataTable SaveUserData(clsUserDetailsModel item)
        {
            DataTable result = new DataTable();

            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new Exception();
            }

            connection = new SqlConnection(connectionString);
            connection.Open();
            if (connection == null)
            {
                throw new Exception();
            }

            SqlCommand command = new SqlCommand("tblUserSave", connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            command.Parameters.Add(new SqlParameter("@email", item.sUsername));
            command.Parameters.Add(new SqlParameter("@password", item.sPassword));

            result.Load(command.ExecuteReader());
            if (result?.Rows.Count == 0)
            {
                throw new Exception();
            }

            if (connection != null)
            {
                connection.Close();
            }

            return(result);
        }
Ejemplo n.º 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = businessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (!IsPostBack)
                {
                    reports = businessLayer.PurchaseReport();
                    BindData();
                }
            }
            catch (FormatException ex)
            {
                pnlError.Visible        = false;
                lblErrorCredential.Text = ex.Message;
            }
            catch (Exception ex)
            {
                Response.Redirect(string.Format("~/Error.aspx?stat={0}", (int)ErrorStatus.InvalidSession));
            }
        }
Ejemplo n.º 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = businessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (!IsPostBack)
                {
                    List <clsFruitModel>           fruits          = new List <clsFruitModel>();
                    List <clsMeasurementUnitModel> measurementUnit = new List <clsMeasurementUnitModel>();
                    fruits          = master.RetrieveFruits();
                    measurementUnit = master.RetrieveMeasurement();

                    foreach (var item in fruits)
                    {
                        ListItem list = new ListItem(item.sFruitName, item.iFruitId.ToString(), true);
                        drpFruit.Items.Add(list);
                    }

                    foreach (var item in measurementUnit)
                    {
                        ListItem list = new ListItem(item.sMeasurement, item.iMeasurementId.ToString(), true);
                        drpMeasureUnit.Items.Add(list);
                    }

                    drpFruit.SelectedIndex       = 0;
                    drpMeasureUnit.SelectedIndex = 0;

                    selectedFruitId = Request.QueryString["fruitid"] == null?Convert.ToInt32(drpFruit.SelectedValue) : Convert.ToInt32(Request.QueryString["fruitid"]);

                    drpFruit.SelectedValue = selectedFruitId.ToString();
                    LoadFruitByFruitId(selectedFruitId);
                }
            }
            catch (Exception ex)
            {
                switch (Convert.ToInt32(ex.Message))
                {
                case (int)ErrorStatus.LoadCountryMasterDataFail:
                    Response.Redirect(string.Format("~/Error.aspx?stat={0}", (int)ErrorStatus.LoginFail));
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 26
0
 public void AddUser(clsUserDetailsModel item)
 {
 }
Ejemplo n.º 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["Customer"] == null)
                {
                    throw new Exception();
                }

                sessionData = (clsUserDetailsModel)Session["Customer"];
                if (sessionData == null || (sessionData.iUserId == 0 || sessionData.iUserDetailsId == 0))
                {
                    throw new Exception();
                }

                userDetails = businessLayer.GetUserByUserDetailId(sessionData.iUserDetailsId);
                if (userDetails.iUserId == 0 || userDetails.iUserDetailsId == 0)
                {
                    throw new Exception();
                }

                if (!IsPostBack)
                {
                    List <clsCountryModel>  countries = new List <clsCountryModel>();
                    List <clsUserTypeModel> userTypes = new List <clsUserTypeModel>();
                    countries = master.RetrieveCountry();
                    userTypes = master.RetrieveUserType();

                    foreach (var item in countries)
                    {
                        ListItem list = new ListItem(item.sCountryName, item.iCountryId.ToString(), true);
                        drpCountry.Items.Add(list);
                    }

                    foreach (var item in userTypes)
                    {
                        if (item.iUserTypeId == (int)UserType.Admin || item.iUserTypeId == (int)UserType.AdminStaff)
                        {
                            continue;
                        }

                        ListItem list = new ListItem(item.sUserType, item.iUserTypeId.ToString(), true);
                        drpRole.Items.Add(list);
                    }

                    drpCountry.SelectedValue = 1.ToString();
                    drpRole.SelectedValue    = 2.ToString();
                }
            }
            catch (Exception ex)
            {
                switch (Convert.ToInt32(ex.Message))
                {
                case (int)ErrorStatus.LoadCountryMasterDataFail:
                    Response.Redirect(string.Format("~/Error.aspx?stat={0}", (int)ErrorStatus.LoginFail));
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 28
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                clsUserDetailsModel result = new clsUserDetailsModel();

                clsUserDetailsModel data = new clsUserDetailsModel()
                {
                    iUserId          = 0,
                    sUsername        = string.Format("#{0}_{1}@{2}", txtName.Text.Trim(), txtCompany.Text.Trim(), UserType.Supplier.ToString()),
                    sPassword        = UserType.Supplier.ToString(),
                    sReEnterPassword = UserType.Supplier.ToString(),

                    iUserDetailsId = 0,
                    sName          = txtName.Text.Trim(),
                    sSurname       = txtSurname.Text.Trim(),
                    sAddress       = txtAddress.Text.Trim(),
                    iCountryId     = Convert.ToInt32(drpCountry.SelectedValue),

                    sEmail   = txtEmailDetail.Text.Trim(),
                    sFixLine = txtPhoneFix.Text.Trim(),
                    sMobile  = txtPhoneMobile.Text.Trim(),
                    sFax     = txtFax.Text.Trim(),

                    sCompany = txtCompany.Text.Trim(),
                    sBRN     = txtBRN.Text.Trim(),
                    sNote    = txtNote.Text.Trim(),

                    bStatus   = true,
                    eUserType = UserType.Supplier,
                    sWebsite  = "EMPTY"
                };



                if (supplierId == 0)
                {
                    result = businessLayer.SignUp(data);
                    if (result == null || result.iUserId == 0)
                    {
                        throw new Exception();
                    }
                }
                else
                {
                    result = businessLayer.GetUserByUserDetailId(supplierId);
                    data.iUserDetailsId = result.iUserDetailsId;
                    data.iUserId        = result.iUserId;
                    businessLayer.Setting(data);
                }

                pnlErrorCompany.Visible = false;
                pnlErrorContact.Visible = false;
                pnlErrorDetails.Visible = false;
                pnlSuccess.Visible      = true;
            }
            catch (FormatException ex)
            {
                pnlErrorCompany.Visible = false;
                pnlErrorContact.Visible = false;
                pnlErrorDetails.Visible = false;
                pnlSuccess.Visible      = false;

                switch (Convert.ToInt32(ex.Message))
                {
                case (int)ErrorStatus.SignupNameMissing:
                    pnlErrorDetails.Visible = true;
                    lblErrorDetails.Text    = "Please enter owner name";
                    break;

                case (int)ErrorStatus.SignupSurnameMissing:
                    pnlErrorDetails.Visible = true;
                    lblErrorDetails.Text    = "Please enter owner surname";
                    break;

                case (int)ErrorStatus.SignupCompanyMissing:
                    pnlErrorCompany.Visible = true;
                    lblErrorCompany.Text    = "Please enter company name";
                    break;

                case (int)ErrorStatus.SignupUsernameMissing:
                case (int)ErrorStatus.SigupPasswordMissing:
                case (int)ErrorStatus.SignupRePasswordMissing:
                case (int)ErrorStatus.SignupPasswordNotMatch:
                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Response.Redirect(string.Format("Error.aspx?stat={0}", (int)ErrorStatus.AddSupplierFail));
            }
        }
Ejemplo n.º 29
0
 public void Setting(clsUserDetailsModel item)
 {
     UpdateUser(item);
     UpdateUserDetails(item);
 }
Ejemplo n.º 30
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            try
            {
                clsUserDetailsModel data = new clsUserDetailsModel()
                {
                    iUserId          = 0,
                    sUsername        = txtEmail.Text.Trim(),
                    sPassword        = txtPassword.Text.Trim(),
                    sReEnterPassword = txtReEnterPassword.Text.Trim(),

                    iUserDetailsId = 0,
                    sName          = txtName.Text.Trim(),
                    sSurname       = txtSurname.Text.Trim(),
                    sAddress       = txtAddress.Text.Trim(),
                    iCountryId     = Convert.ToInt32(drpCountry.SelectedValue),

                    sEmail   = txtEmailDetail.Text.Trim(),
                    sFixLine = txtPhoneFix.Text.Trim(),
                    sMobile  = txtPhoneMobile.Text.Trim(),

                    sCompany = txtCompany.Text.Trim(),
                    sBRN     = txtBRN.Text.Trim(),
                    sNote    = txtNote.Text.Trim(),

                    bStatus   = true,
                    eUserType = UserType.Customer
                };

                clsUserDetailsModel result = new clsUserDetailsModel();
                result = businessLayer.SignUp(data);

                if (result == null || result.iUserId == 0)
                {
                    throw new Exception();
                }

                Session["Customer"] = result;
                Response.Redirect("~/WebForms/Main/Details.aspx", false);
            }
            catch (FormatException ex)
            {
                pnlErrorCompany.Visible    = false;
                pnlErrorContact.Visible    = false;
                pnlErrorCredential.Visible = false;
                pnlErrorDetails.Visible    = false;

                switch (Convert.ToInt32(ex.Message))
                {
                case (int)ErrorStatus.SignupUsernameMissing:
                    pnlErrorCredential.Visible = true;
                    lblErrorCredential.Text    = "Please enter email address";
                    break;

                case (int)ErrorStatus.SigupPasswordMissing:
                    pnlErrorCredential.Visible = true;
                    lblErrorCredential.Text    = "Please enter password";
                    break;

                case (int)ErrorStatus.SignupRePasswordMissing:
                    pnlErrorCredential.Visible = true;
                    lblErrorCredential.Text    = "Please re enter password";
                    break;

                case (int)ErrorStatus.SignupPasswordNotMatch:
                    pnlErrorCredential.Visible = true;
                    lblErrorCredential.Text    = "Password does not match";
                    break;

                case (int)ErrorStatus.SignupNameMissing:
                    pnlErrorDetails.Visible = true;
                    lblErrorDetails.Text    = "Please enter owner name";
                    break;

                case (int)ErrorStatus.SignupSurnameMissing:
                    pnlErrorDetails.Visible = true;
                    lblErrorDetails.Text    = "Please enter owner surname";
                    break;

                case (int)ErrorStatus.SignupCompanyMissing:
                    pnlErrorCompany.Visible = true;
                    lblErrorCompany.Text    = "Please enter company name";
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Response.Redirect(string.Format("Error.aspx?stat={0}", (int)ErrorStatus.SignUpFail));
            }
        }