Exemple #1
0
        private void PublicAuthenticationPassword_Load(object sender, EventArgs e)
        {
            try
            {
                UserAPIs userAPIs     = new UserAPIs(CommonNinject.Kernel.Get <IUserAPIRepository>());
                string   passwordHash = userAPIs.GetPasswordHash(ContextAttributes.User.UserID);
                if (passwordHash != "")
                {
                    passwordHash = SecurePassword.Decrypt(passwordHash);
                }

                this.textBoxCurrentPassword.Tag = passwordHash;

                this.SetButtonEnabled();
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }
Exemple #2
0
        private void buttonLoginExit_Click(object sender, EventArgs e)
        {
            try
            {
                if (!(GlobalVariables.ConfigID == (int)GlobalEnums.NmvnTaskID.Lavie || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Smallpack || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.Pail || GlobalVariables.ConfigID == (int)GlobalVariables.FillingLine.BatchMaster))
                {
                    CustomMsgBox.Show(this, "Sorry, can not open this application." + "\r\n" + "\r\n" + "Call 0919 878 329 for more information. Thanks!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.DialogResult = DialogResult.Cancel; return;
                }

                if (sender.Equals(this.buttonExit))
                {
                    this.DialogResult = DialogResult.Cancel; return;
                }

                if (this.comboBoxEmployeeID.SelectedIndex >= 0)
                {
                    ActiveUser activeUser = this.comboBoxEmployeeID.SelectedItem as ActiveUser;
                    if (activeUser != null)
                    {
                        UserAPIs userAPIs     = new UserAPIs(CommonNinject.Kernel.Get <IUserAPIRepository>());
                        string   passwordHash = userAPIs.GetPasswordHash(activeUser.UserID);
                        if (passwordHash != "")
                        {
                            passwordHash = SecurePassword.Decrypt(passwordHash);
                        }
                        if (this.textPassword.Text != passwordHash)
                        {
                            throw new Exception("Sai mật khẩu. Vui lòng nhập lại mật khẩu trước khi tiếp tục.");
                        }


                        ContextAttributes.User = new UserInformation(activeUser.UserID, activeUser.OrganizationalUnitID, activeUser.LocationID, activeUser.LocationName, activeUser.UserName, activeUser.SecurityIdentifier, activeUser.FullyQualifiedUserName, activeUser.IsDatabaseAdmin, new DateTime());

                        if (this.comboFillingLineID.Visible && (this.comboFillingLineID.SelectedIndex < 0 || this.comboBoxAutonicsPortName.SelectedIndex < 0))
                        {
                            throw new System.ArgumentException("Vui lòng chọn chuyền sản xuất (NOF1, NOF2, NOF...), và chọn đúng cổng COM để chạy phần mềm");                                                                                                                                    // || (this.comboFillingLineID.Enabled && (GlobalVariables.ProductionLine)this.comboFillingLineID.SelectedValue == GlobalVariables.ProductionLine.SERVER)
                        }
                        if (this.comboFillingLineID.Visible)
                        {
                            GlobalVariables.FillingLineID          = (GlobalVariables.FillingLine) this.comboFillingLineID.SelectedValue;
                            GlobalVariables.FillingLineCode        = ((FillingLineBase)this.comboFillingLineID.SelectedItem).Code;
                            GlobalVariables.FillingLineName        = ((FillingLineBase)this.comboFillingLineID.SelectedItem).Name;
                            GlobalVariables.FillingLineFactoryCode = ((FillingLineBase)this.comboFillingLineID.SelectedItem).FactoryCode;
                        }
                        else
                        {
                            GlobalVariables.FillingLineID = GlobalVariables.FillingLine.None;
                        }

                        GlobalVariables.ComportName = (string)this.comboBoxAutonicsPortName.SelectedValue;

                        CommonConfigs.AddUpdateAppSetting("ConfigID", (GlobalVariables.ConfigID).ToString());
                        CommonConfigs.AddUpdateAppSetting("ComportName", GlobalVariables.ComportName);

                        //CommonConfigs.AddUpdateAppSetting("ReportServerUrl", GlobalVariables.ReportServerUrl); //WILL BE REMOVE THIS LINE
                        GlobalVariables.ReportServerUrl = CommonConfigs.ReadSetting("ReportServerUrl");

                        this.VersionValidate();

                        #region EMPTY DATABASE
                        if (false && this.checkEmptyData.Checked)
                        {
                            this.baseRepository.ExecuteStoreCommand("UPDATE GoodsReceipts SET PickupID = NULL, GoodsIssueID = NULL, WarehouseAdjustmentID = NULL", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("UPDATE GoodsReceiptDetails SET PickupDetailID = NULL, PickupID = NULL, GoodsIssueTransferDetailID = NULL, GoodsIssueID = NULL, WarehouseAdjustmentDetailID = NULL, WarehouseAdjustmentID = NULL", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     WarehouseAdjustmentDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('WarehouseAdjustmentDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     WarehouseAdjustments", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('WarehouseAdjustments', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsIssueTransferDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssueTransferDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsIssueDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssueDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsIssues", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssues', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     TransferOrderDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('TransferOrderDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     TransferOrders", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('TransferOrders', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     DeliveryAdviceDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('DeliveryAdviceDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     DeliveryAdvices", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('DeliveryAdvices', RESEED, 0)", new ObjectParameter[] { });


                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     SalesOrderDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('SalesOrderDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     SalesOrders", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('SalesOrders', RESEED, 0)", new ObjectParameter[] { });



                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsReceiptDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsReceiptDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsReceipts", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsReceipts', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     PickupDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('PickupDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Pickups", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Pickups', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Packs", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Packs', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Cartons", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Cartons', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Pallets", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Pallets', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Batches", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Batches', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Lots", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Lots', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     BatchMasters", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('BatchMasters', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Commodities", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Commodities', RESEED, 0)", new ObjectParameter[] { });
                        }
                        #endregion

                        if (this.baseRepository.AutoUpdates(sender.Equals(this.buttonLoginRestore)))
                        {
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            CustomMsgBox.Show(this, "The program on this computer must be updated to the latest version." + "\r\n" + "\r\n" + "Contact your administrator for more information.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            this.buttonDownload_Click(this.buttonDownload, new EventArgs());
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);

                this.DialogResult = DialogResult.None;
            }
        }