示例#1
0
        private void cboAuthenticationType_SelectionChangeCommitted(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            if (cboAuthenticationType.SelectedIndex == 0)
            {
                clsDMCommon.ObjCon.ConnectionString = "Server=" + clsDMCommon.strServerName + ";Database=" + ClientDBName + ";uid=" + clsDMCommon.strUserID
                                                      + ";pwd= " + clsDMCommon.strUserPassword + ";" + "Max Pool Size = 5004;Pooling=True";

                clsConnection_DAL ObjDAL = new clsConnection_DAL();
                ObjDAL.SetConnectionString(clsDMCommon.ObjCon.ConnectionString);
                if (ObjDAL.IsDatabaseExist(ClientDBName))
                {
                    if (!System.IO.Directory.Exists("AppConfig"))
                    {
                        System.IO.Directory.CreateDirectory("AppConfig");
                        File.WriteAllText("AppConfig\\ServerConfig.sc", ObjUtil.Encrypt(clsDMCommon.ObjCon.ConnectionString, true));
                    }
                    clsUtility.ShowInfoMessage("Database is already exist.\n please select client", clsUtility.strProjectTitle);
                    IsConnect = false;
                }
                else
                {
                    grpDBRestore.Enabled = true;
                    txtDabasePath.Focus();
                }
            }
            else if (cboAuthenticationType.SelectedIndex == 1)
            {
                grpDBRestore.Enabled = false;
                ConnectToDB(clsDMCommon.strServerName, clsDMCommon.strUserID, clsDMCommon.strUserPassword, ClientDBName);

                String conn = "Server=" + clsDMCommon.strServerName + ";Database=" + ClientDBName + ";uid=" + clsDMCommon.strUserID
                              + ";pwd= " + clsDMCommon.strUserPassword + ";" + "Max Pool Size = 5004;Pooling=True";
                String EncrConn = ObjUtil.Encrypt(conn, true);
                if (!System.IO.Directory.Exists("AppConfig"))
                {
                    System.IO.Directory.CreateDirectory("AppConfig");
                    File.WriteAllText("AppConfig\\ServerConfig.sc", EncrConn);
                }

                ObjDAL = new clsConnection_DAL(true);
                //DataTable dt = ObjDAL.GetDataCol(ClientDBName + ".dbo.RegistrationDetails", "RegistrationID", "PcName = '"+ Environment.MachineName+"'", null);
                int a = ObjDAL.CountRecords(ClientDBName + ".dbo.RegistrationDetails", "PcName = '" + Environment.MachineName + "'");
                //if (dt == null || dt.Rows.Count == 0)
                if (a == 0)
                {
                    InsertClientRegistration();
                }
                else
                {
                    clsUtility.ShowInfoMessage("Client is already Registered.", clsUtility.strProjectTitle);
                    Application.Exit();
                }
            }
            this.Cursor = Cursors.Default;
        }
示例#2
0
        private void RestoreDataBase()
        {
            try
            {
                clsDMCommon.ObjCon.ConnectionString = "Server=" + clsDMCommon.strServerName + ";Database=master;uid="
                                                      + clsDMCommon.strUserID + ";pwd= " + clsDMCommon.strUserPassword + ";" + "Max Pool Size = 5004;Pooling=True";
                if (clsDMCommon.ObjCon.State == ConnectionState.Closed)
                {
                    clsDMCommon.ObjCon.Open();
                }
                string     sqlcmd = "RESTORE DATABASE " + strRDatabseName + " FROM DISK='" + strRestorePath + "' with replace";
                SqlCommand cmd    = new SqlCommand(sqlcmd, clsDMCommon.ObjCon);
                cmd.ExecuteNonQuery();
                clsDMCommon.ObjCon.Close();
                CloseLoading();

                String conn = "Server=" + clsDMCommon.strServerName + ";Database=" + strRDatabseName + ";uid=" + clsDMCommon.strUserID
                              + ";pwd= " + clsDMCommon.strUserPassword + ";" + "Max Pool Size = 5004;Pooling=True";
                String EncrConn = ObjUtil.Encrypt(conn, true);
                if (!Directory.Exists("AppConfig"))
                {
                    System.IO.Directory.CreateDirectory("AppConfig");
                    File.WriteAllText("AppConfig\\ServerConfig.sc", EncrConn);
                }

                clsDMCommon.ObjCon.ConnectionString = conn; //for loading connection string for frmCustomerRegister
                clsConnection_DAL ObjDAL = new clsConnection_DAL(true);
                ObjDAL.SetColumnData("PcName", SqlDbType.NVarChar, Environment.MachineName);
                ObjDAL.SetColumnData("StatusDate", SqlDbType.VarChar, ObjUtil.Encrypt(DateTime.Now.ToString("yyyy/MM/dd"), true));
                ObjDAL.SetColumnData("IsTrail", SqlDbType.Bit, 1);
                ObjDAL.SetColumnData("RegDate", SqlDbType.Date, DateTime.Now);
                ObjDAL.SetColumnData("ExpiryDate", SqlDbType.VarChar, ObjUtil.Encrypt(DateTime.Now.AddDays(7).ToString("yyyy/MM/dd"), true));
                ObjDAL.SetColumnData("IsKeyEnter", SqlDbType.Bit, 0);
                ObjDAL.SetColumnData("IsServer", SqlDbType.Bit, 1);

                if (ObjDAL.InsertData(strRDatabseName + ".dbo.RegistrationDetails", true) > 0)
                {
                    clsUtility.ShowInfoMessage("RESTORE DATABASE successfully.", clsUtility.strProjectTitle);
                }
            }
            catch (Exception ex)
            {
                clsDMCommon.ObjCon.Close();
                CloseLoading();
                clsUtility.ShowErrorMessage(ex.ToString(), clsUtility.strProjectTitle);
            }
            //RESTORE DATABASE database_name FROM backup_device WITH RECOVERY
        }
示例#3
0
        byte i       = 0; //for closing Registrationprocess if system datetime is changes

        private void SplashWindow_Load(object sender, EventArgs e)
        {
            lblversion.Text            = lblversion.Text + " " + Application.ProductVersion;
            clsUtility.strProjectTitle = "Inventory Management System";

            if (System.IO.Directory.Exists("AppConfig") && System.IO.File.Exists("AppConfig\\ServerConfig.sc"))
            {
                ObjDAL            = new clsConnection_DAL(true);
                clsUtility.DBName = ObjDAL.GetCurrentDBName(true);
                AddStatusDate();// for adding current datetime if current datetime is greater than previous statusdate's datetime
                IsPath = true;
            }
            else
            {
                lblStatus.Text = lblStatus.Text + " UnRegistered Version";
            }
            timer1.Enabled = true;
            timer1.Start();
        }
        public static string GetPrinterName(PrinterType printerType)
        {
            CoreApp.clsConnection_DAL ObjCon = new clsConnection_DAL(true);
            string printerName = "";

            if (printerType == PrinterType.BarCodePrinter)
            {
                DataTable dtPrinter = ObjCon.ExecuteSelectStatement("SELECT * FROM [tblPrinterSetting] WITH(NOLOCK) WHERE machineName='" + Environment.MachineName + "' ");
                if (dtPrinter.Rows.Count > 0)
                {
                    printerName = dtPrinter.Rows[0]["BarCodePrinter"].ToString();
                }
            }
            else if (printerType == PrinterType.InvoicePrinter)
            {
                DataTable dtPrinter = ObjCon.ExecuteSelectStatement("SELECT * FROM [tblPrinterSetting] WITH(NOLOCK) WHERE machineName='" + Environment.MachineName + "' ");
                if (dtPrinter.Rows.Count > 0)
                {
                    printerName = dtPrinter.Rows[0]["InvoicePrinter"].ToString();
                }
            }
            return(printerName);
        }