Esempio n. 1
0
        static void runApp()
        {
            try
            {
                Application.Run(new Login());
            }
            catch (ArgumentOutOfRangeException e)
            {
                if (e.Message.Contains("'1401'"))
                {
                    PopUp popup;
                    popup = new PopUp("خطای تاریخ ورودی", "تاریخ غیرمجاز: این نسخه از نرم افزار از تاریخ ورودی پشتیبانی نمی کند", "تایید", "", "", "error");
                    popup.ShowDialog();

                    runApp();
                }
            }
        }
Esempio n. 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Waiting());
            //Application.Run(new Form1());
            try
            {
                runApp();
            }
            catch (ArgumentOutOfRangeException e)
            {
                if (e.Message.Contains("'1401'"))
                {
                    PopUp popup;
                    popup = new PopUp("خطای تاریخ ورودی", "تاریخ غیرمجاز: این نسخه از نرم افزار از تاریخ ورودی پشتیبانی نمی کند", "تایید", "", "", "error");
                    popup.ShowDialog();

                    runApp();
                }
            }
        }
Esempio n. 3
0
        private void reportFastPrintBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (reportTitleTxtbx.Text == "")
                {
                    PopUp p = new PopUp("ریپورت بدون عنوان", "عنوانی برای ریپورت وارد نکرده اید. ادامه می دهید؟", "بله", "خیر", "", "info");
                    p.ShowDialog();
                    if (p.DialogResult == DialogResult.Yes)
                    {
                        DataTable dt = new DataTable();
                        foreach (DataGridViewColumn col in reportDataGridView.Columns)
                        {
                            dt.Columns.Add(col.Name);
                        }

                        foreach (DataGridViewRow row in reportDataGridView.Rows)
                        {
                            DataRow dRow = dt.NewRow();
                            foreach (DataGridViewCell cell in row.Cells)
                            {
                                if (cell.ColumnIndex == 14)
                                {
                                    string temp = string.Format("{0:n0}", double.Parse(cell.Value.ToString()));
                                    temp = temp.Replace(',', '/');
                                    dRow[cell.ColumnIndex] = temp;
                                }
                                else
                                {
                                    dRow[cell.ColumnIndex] = cell.Value;
                                }
                            }
                            dt.Rows.Add(dRow);
                        }

                        //DataTable dt = (DataTable)(searchProposalShowDgv.DataSource);

                        Report report = new Report();
                        report.Load("report1.frx");
                        report.SetParameterValue("r_title", reportTitleTxtbx.Text.ToString());
                        report.SetParameterValue("r_totalRecords", reportDataGridView.Rows.Count.ToString());
                        report.SetParameterValue("r_userInfo", user.U_LName);
                        report.SetParameterValue("r_userTel", user.U_Tel);
                        report.SetParameterValue("r_dateInfo", dbh.getDateHijri(DateTime.Now.ToString()));
                        //TableDataSource table = report.GetDataSource("proposalTable") as TableDataSource;
                        report.RegisterData(dt, "proposalTable");
                        report.GetDataSource("proposalTable").Enabled = true;
                        report.Prepare();
                        report.Print();
                    }
                    else
                    {
                        reportTitleTxtbx.Focus();
                    }
                }
                else
                {
                    DataTable dt = new DataTable();
                    foreach (DataGridViewColumn col in reportDataGridView.Columns)
                    {
                        dt.Columns.Add(col.Name);
                    }

                    foreach (DataGridViewRow row in reportDataGridView.Rows)
                    {
                        DataRow dRow = dt.NewRow();
                        foreach (DataGridViewCell cell in row.Cells)
                        {
                            if (cell.ColumnIndex == 14)
                            {
                                string temp = string.Format("{0:n0}", double.Parse(cell.Value.ToString()));
                                temp = temp.Replace(',', '/');
                                dRow[cell.ColumnIndex] = temp;
                            }
                            else
                            {
                                dRow[cell.ColumnIndex] = cell.Value;
                            }
                        }
                        dt.Rows.Add(dRow);
                    }

                    //DataTable dt = (DataTable)(searchProposalShowDgv.DataSource);

                    Report report = new Report();
                    report.Load("report1.frx");
                    report.SetParameterValue("r_title", reportTitleTxtbx.Text.ToString());
                    report.SetParameterValue("r_totalRecords", reportDataGridView.Rows.Count.ToString());
                    report.SetParameterValue("r_userInfo", user.U_LName);
                    report.SetParameterValue("r_userTel", user.U_Tel);
                    report.SetParameterValue("r_dateInfo", dbh.getDateHijri(DateTime.Now.ToString()));
                    //TableDataSource table = report.GetDataSource("proposalTable") as TableDataSource;
                    report.RegisterData(dt, "proposalTable");
                    report.GetDataSource("proposalTable").Enabled = true;
                    report.Prepare();
                    report.Print();
                }
            }
            catch (Exception ee)
            {
                if (user.U_NCode == 999999999) // to show exceptin for admin
                {
                    MessageBox.Show(ee.Message);
                }
                string context = "خطای فایل نامه";
                Alert  alert   = new Alert(context, "bluegray", 15);
            }
        }
Esempio n. 4
0
        private void loginEnterBtn_Click(object sender, EventArgs e)
        {
            try
            {
                /*SqlConnection conn2 = new SqlConnection();
                 *
                 * SqlCommand sc2 = new SqlCommand();
                 * //conn2.ConnectionString = "Data Source= 185.159.152.2;" +
                 * //"Initial Catalog=rayanpro_EBS;" +
                 * //"User id=rayanpro_rayan; " +
                 * //"Password=P@hn1395;";
                 * conn2.ConnectionString = "Data Source= 169.254.92.252;" +
                 * "Initial Catalog=rayanpro_EBS;" +
                 * "User id=test; " +
                 * "Password=HoseinNima1234;";
                 *
                 * sc2.Connection = conn2;
                 *
                 * conn2.Open();*/

                try
                {
                    if (loginUsernameTxtBx.Text == "" || loginPasswordTxtbx.Text == "")
                    {
                        string context = "نام کاربری یا رمز عبور وارد نشده است";
                        Alert  alert   = new Alert(context, "darkred", 5);
                    }
                    else if (loginUsernameTxtBx.Text == "999999999" && loginPasswordTxtbx.Text == "P@hn1395")
                    {
                        username = loginUsernameTxtBx.Text;
                        password = loginPasswordTxtbx.Text;

                        // REMEMBERING PASSWORD
                        if (loginRememberUsername.Checked)
                        {
                            remembering[0] = "yes";
                            remembering[1] = username;
                            File.WriteAllLines("loginInformation", remembering);
                        }
                        else
                        {
                            remembering[0] = "no";
                            remembering[1] = "-";
                            File.WriteAllLines("loginInformation", remembering);
                        }
                        // REMEMBERING PASSWORD

                        ServerInfo server = new ServerInfo();
                        this.Hide();
                        server.Show();
                    }

                    else
                    {
                        DataBaseHandler dbh     = new DataBaseHandler(user);
                        AppSetting      setting = new AppSetting();
                        username = loginUsernameTxtBx.Text;
                        password = dbh.hashPass(loginPasswordTxtbx.Text);

                        SqlConnection conn = new SqlConnection();
                        //conn.ConnectionString = "Data Source= 185.159.152.2;" +
                        //"Initial Catalog=rayanpro_EBS;" +
                        //"User id=rayanpro_rayan; " +
                        //"Password=P@hn1395;";

                        /* conn.ConnectionString = "Data Source= 169.254.92.252;" +
                         * "Initial Catalog=rayanpro_EBS;" +
                         * "User id=test; " +
                         * "Password=HoseinNima1234;";*/

                        conn.ConnectionString = setting.getConnectionString("cn");

                        SqlCommand sc = new SqlCommand();
                        sc.CommandTimeout = 5;
                        SqlDataReader reader;
                        sc.CommandText = "SELECT * FROM UsersTable WHERE u_NCode = '" + long.Parse(username) + "' AND u_Password = '******'";
                        sc.CommandType = CommandType.Text;
                        sc.Connection  = conn;
                        conn.Open();
                        reader = sc.ExecuteReader();
                        if (reader.HasRows)
                        {
                            // REMEMBERING PASSWORD
                            if (loginRememberUsername.Checked)
                            {
                                remembering[0] = "yes";
                                remembering[1] = username;
                                File.WriteAllLines("loginInformation", remembering);
                            }
                            else
                            {
                                remembering[0] = "no";
                                remembering[1] = "-";
                                File.WriteAllLines("loginInformation", remembering);
                            }
                            // REMEMBERING PASSWORD

                            reader.Read();

                            user.U_FName    = reader["u_FName"].ToString();
                            user.U_LName    = reader["u_LName"].ToString();
                            user.U_NCode    = long.Parse(reader["u_NCode"].ToString());
                            user.U_Password = reader["u_Password"].ToString();
                            user.U_Email    = reader["u_Email"].ToString();
                            user.U_Tel      = reader["u_Tel"].ToString();

                            if (reader["u_IsAdmin"].ToString() == "True")
                            {
                                user.U_IsAdmin = 1;
                            }
                            else
                            {
                                user.U_IsAdmin = 0;
                            }

                            if (reader["u_canAddProposal"].ToString() == "True")
                            {
                                user.CanAddProposal = 1;
                            }
                            else
                            {
                                user.CanAddProposal = 0;
                            }

                            if (reader["u_canEditProposal"].ToString() == "True")
                            {
                                user.CanEditProposal = 1;
                            }
                            else
                            {
                                user.CanEditProposal = 0;
                            }

                            if (reader["u_canDeleteProposal"].ToString() == "True")
                            {
                                user.CanDeleteProposal = 1;
                            }
                            else
                            {
                                user.CanDeleteProposal = 0;
                            }

                            if (reader["u_canAddUser"].ToString() == "True")
                            {
                                user.CanAddUser = 1;
                            }
                            else
                            {
                                user.CanAddUser = 0;
                            }

                            if (reader["u_canEditUser"].ToString() == "True")
                            {
                                user.CanEditUser = 1;
                            }
                            else
                            {
                                user.CanEditUser = 0;
                            }

                            if (reader["u_canDeleteUser"].ToString() == "True")
                            {
                                user.CanDeleteUser = 1;
                            }
                            else
                            {
                                user.CanDeleteUser = 0;
                            }

                            if (reader["u_canManageTeacher"].ToString() == "True")
                            {
                                user.CanManageTeacher = 1;
                            }
                            else
                            {
                                user.CanManageTeacher = 0;
                            }

                            if (reader["u_canManageType"].ToString() == "True")
                            {
                                user.CanManageType = 1;
                            }
                            else
                            {
                                user.CanManageType = 0;
                            }

                            if (Int16.Parse(reader["u_otherAccess"].ToString()) == 1)
                            {
                                user.U_otherAccess = 1; // Read Only User
                            }
                            else
                            {
                                user.U_otherAccess = 0;
                            }

                            user.U_Color   = reader["u_Color"].ToString();
                            user.U_Faculty = reader["u_faculty"].ToString();

                            this.Hide();
                            Form1 mainForm = new Form1(user);
                            mainForm.Show();
                        }
                        else
                        {
                            //PopUp popUp = new PopUp("خطا", "نام کاربری یا رمز عبور اشتباه است.", "تایید", "", "", "error");
                            //popUp.ShowDialog();
                            string context = "نام کاربری یا رمز عبور اشتباه است";
                            Alert  alert   = new Alert(context, "darkred", 5);
                        }
                        conn.Close();
                    }
                }
                catch (SqlException)
                {
                    PopUp popUp = new PopUp("خطا", "خطا در برقراری ارتباط با سرور", "تایید", "", "", "error");
                    popUp.ShowDialog();
                }
            }
            catch
            {
                string context = "خطا در برقراری ارتباط با سرور";
                Alert  alert   = new Alert(context, "darkred", 5);
            }
        }