Beispiel #1
0
        public void btnInventory_Click(object sender, EventArgs e)
        {
            if (parentForm.StoreCode.ToUpper().ToString() == parentForm.WarehouseStoreCode1.ToUpper() & parentForm.storeName.ToUpper().ToString() == parentForm.WarehouseName1.ToUpper())
            {
                if (parentForm.employeeID.ToUpper().ToString() == parentForm.SystemMasterUserName.ToUpper())
                {
                    Authorized = true;
                }
                else
                {
                    if (Authorized == false)
                    {
                        BtnInventory = false;
                    }
                    else
                    {
                        BtnInventory = true;
                    }
                }
            }
            else
            {
                BtnInventory = true;
            }

            try
            {
                if (BtnInventory == true)
                {
                    SqlCommand cmd = new SqlCommand("Check_User", parentForm.conn);

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@empLoginID", SqlDbType.NVarChar).Value = parentForm.employeeID.ToUpper().ToString();
                    SqlParameter UserName_Param = cmd.Parameters.Add("@empFirstName", SqlDbType.NVarChar, 50);
                    UserName_Param.Direction = ParameterDirection.Output;

                    parentForm.conn.Open();
                    cmd.ExecuteNonQuery();
                    parentForm.conn.Close();

                    if (cmd.Parameters["@empFirstName"].Value == DBNull.Value)
                    {
                        if (parentForm.employeeID == parentForm.SystemMasterUserName)
                        {
                            if (parentForm.StoreCode == "B4UHQ")
                            {
                                InventoryMainHQ inventoryMainHQForm = new InventoryMainHQ();
                                inventoryMainHQForm.parentForm = this.parentForm;
                                inventoryMainHQForm.Show();
                            }
                            else
                            {
                                InventoryMain inventoryMainForm = new InventoryMain();
                                inventoryMainForm.parentForm = this.parentForm;
                                inventoryMainForm.Show();
                            }
                        }
                        else
                        {
                            MessageBox.Show("NOT AUTHORIZED", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    else
                    {
                        if (parentForm.userLevel >= parentForm.btnManagementInventory)
                        {
                            if (parentForm.StoreCode == "B4UHQ")
                            {
                                InventoryMainHQ inventoryMainHQForm = new InventoryMainHQ();
                                inventoryMainHQForm.parentForm = this.parentForm;
                                inventoryMainHQForm.Show();
                            }
                            else
                            {
                                InventoryMain inventoryMainForm = new InventoryMain();
                                inventoryMainForm.parentForm = this.parentForm;
                                inventoryMainForm.Show();
                            }
                        }
                        else
                        {
                            MessageBox.Show("NOT AUTHORIZED", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                }
                else
                {
                    InputPasscode inputPasscodeFrom = new InputPasscode(1);
                    inputPasscodeFrom.parentForm1 = this.parentForm;
                    inputPasscodeFrom.parentForm2 = this;
                    inputPasscodeFrom.Show();
                }
            }
            catch
            {
                MessageBox.Show("CAN NOT CONNECT TO SERVER...", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                parentForm.conn.Close();
                return;
            }
        }
Beispiel #2
0
        private void btnUpdateCheck_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = new SqlConnection(parentForm.B4UHQCS_IP);
                SqlCommand    cmd  = new SqlCommand("ClientVersionCheck", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@ClientName", SqlDbType.NVarChar).Value = clientName;
                SqlParameter ClientVersion_Param  = cmd.Parameters.Add("@ClientVersion", SqlDbType.Int);
                SqlParameter UpdatePassword_Param = cmd.Parameters.Add("@UpdatePassword", SqlDbType.NVarChar, 50);
                SqlParameter FTPUserName_Param    = cmd.Parameters.Add("@FTPUserName", SqlDbType.NVarChar, 50);
                SqlParameter FTPPassword_Param    = cmd.Parameters.Add("@FTPPassword", SqlDbType.NVarChar, 50);
                ClientVersion_Param.Direction  = ParameterDirection.Output;
                UpdatePassword_Param.Direction = ParameterDirection.Output;
                FTPUserName_Param.Direction    = ParameterDirection.Output;
                FTPPassword_Param.Direction    = ParameterDirection.Output;

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();

                if (cmd.Parameters["@UpdatePassword"].Value == DBNull.Value)
                {
                    updatePassword = "******";
                }
                else
                {
                    updatePassword = cmd.Parameters["@UpdatePassword"].Value.ToString().Trim();
                }

                lastestClientVersion = Convert.ToInt16(cmd.Parameters["@ClientVersion"].Value);
                _UserName            = cmd.Parameters["@FTPUserName"].Value.ToString().Trim();
                _Password            = cmd.Parameters["@FTPPassword"].Value.ToString().Trim();

                if (lastestClientVersion > currentClientVersion)
                {
                    if (btnUpdateCheck.Text == "UPDATE")
                    {
                        listBox1.DataSource = GetFtpDirectoryDetails(_ftpURL + FTPDirectoryName, _UserName, _Password);
                        string[] fileList = GetFileList(_ftpURL + FTPDirectoryName, _UserName, _Password);

                        if (fileList.Length > 50)
                        {
                            MessageBox.Show("Can not download more than 50 files. \r\nPlese contact IT department.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else if (fileList.Length == 1)
                        {
                            progressBar1.Minimum = 0;
                            progressBar1.Maximum = 1;
                            progressBar1.Step    = 1;
                            //ret_str += fileList[0];
                            DownloadFile(_ftpURL, _UserName, _Password, FTPDirectoryName, fileList[0].Substring(11), LocalDirectory, 0);
                            progressBar1.PerformStep();

                            MessageBox.Show("Update completes successfully! \r\nPlease hit OK button to restart the program...", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            btnUpdateCheck.Enabled = false;
                            Application.Restart();
                        }
                        else
                        {
                            progressBar1.Minimum = 0;
                            progressBar1.Maximum = fileList.Length;
                            progressBar1.Step    = 1;

                            for (int i = 0; i < fileList.Length; i++)
                            {
                                oldfile[i] = fileList[i].Substring(11);
                                //ret_str += fileList[i] + ",";
                                DownloadFile(_ftpURL, _UserName, _Password, FTPDirectoryName, oldfile[i], LocalDirectory, i);
                                progressBar1.PerformStep();
                            }

                            MessageBox.Show("Update completes successfully! \r\nPlease hit OK button to restart the program...", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            btnUpdateCheck.Enabled = false;
                            Application.Restart();
                        }
                    }
                    else
                    {
                        DialogResult MyDialogResult;
                        MyDialogResult = MessageBox.Show(this, "A new version of POS MANAGEMENT program client is available. \r\nDo you want to proceed with the update now?", "QUESTION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        if (MyDialogResult == DialogResult.Yes)
                        {
                            if (auth == false)
                            {
                                InputPasscode inputPasscodeForm = new InputPasscode(3);
                                inputPasscodeForm.parentForm1 = this.parentForm;
                                inputPasscodeForm.parentForm5 = this;
                                inputPasscodeForm.ShowDialog();
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No update is available.", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch
            {
                MessageBox.Show("Can not connect the update server...", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #3
0
        public void btnSalesByStore_Click(object sender, EventArgs e)
        {
            if (parentForm.userLevel >= parentForm.GeneralManagerLV)
            {
                Authorized = true;
            }
            else
            {
                if (Authorized == false)
                {
                    BtnSalesByStore = false;
                }
                else
                {
                    BtnSalesByStore = true;
                }
            }

            try
            {
                if (BtnSalesByStore == true)
                {
                    SqlCommand cmd = new SqlCommand("Check_User", parentForm.conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@empLoginID", SqlDbType.NVarChar).Value = parentForm.employeeID.ToUpper().ToString();
                    SqlParameter UserName_Param = cmd.Parameters.Add("@empFirstName", SqlDbType.NVarChar, 50);
                    UserName_Param.Direction = ParameterDirection.Output;

                    parentForm.conn.Open();
                    cmd.ExecuteNonQuery();
                    parentForm.conn.Close();

                    if (cmd.Parameters["@empFirstName"].Value == DBNull.Value)
                    {
                        if (parentForm.employeeID == parentForm.SystemMasterUserName)
                        {
                            SalesHistoryByStore salesHistoryByStoreForm = new SalesHistoryByStore();
                            salesHistoryByStoreForm.parentForm = this.parentForm;
                            salesHistoryByStoreForm.Show();
                        }
                        else
                        {
                            MessageBox.Show("NOT AUTHORIZED", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    else
                    {
                        if (parentForm.userLevel >= parentForm.SectionManagerLV)
                        {
                            SalesHistoryByStore salesHistoryByStoreForm = new SalesHistoryByStore();
                            salesHistoryByStoreForm.parentForm = this.parentForm;
                            salesHistoryByStoreForm.Show();
                        }
                        else
                        {
                            MessageBox.Show("NOT AUTHORIZED", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                }
                else
                {
                    InputPasscode inputPasscodeFrom = new InputPasscode(0);
                    inputPasscodeFrom.parentForm1 = this.parentForm;
                    inputPasscodeFrom.parentForm3 = this;
                    inputPasscodeFrom.Show();
                }
            }
            catch
            {
                MessageBox.Show("CAN NOT CONNECT TO SERVER...", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                parentForm.conn.Close();
                return;
            }

            /*if (parentForm.userLevel > 5)
             * {
             *  SalesHistoryByStore salesHistoryByStoreForm = new SalesHistoryByStore();
             *  salesHistoryByStoreForm.Show();
             * }
             * else
             * {
             *  MessageBox.Show("NOT AUTHORIZED", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  return;
             * }*/

            //SalesHistoryByStore salesHistoryByStoreForm = new SalesHistoryByStore();
            //salesHistoryByStoreForm.parentForm = this.parentForm;
            //salesHistoryByStoreForm.Show();
        }