Пример #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            BonusSkins.Register();
            SkinManager.EnableFormSkins();
            UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");
            //Application.Run(new FrmTienDo());
            if (new frm_ChangeServer().ShowDialog() != DialogResult.OK)
            {
                return;
            }
            bool temp = false;

            do
            {
                temp = false;

                frmLogin frLogin = new frmLogin();
                if (frLogin.ShowDialog() == DialogResult.OK)
                {
                    frm_Main frMain = new frm_Main();

                    if (frMain.ShowDialog() == DialogResult.Yes)
                    {
                        frMain.Close();
                        temp = true;
                    }
                }
            }while (temp);
        }
Пример #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new frm_Main());
            bool temp;

            do
            {
                temp = false;
                Frm_Login a = new Frm_Login();
                a.lb_programName.Text = "          Chương trình\n        Nencho";
                a.lb_version.Text     = @"1.0";
                a.UrlUpdateVersion    = @"\\10.10.10.254\DE_Viet\2016\PHIẾU KIỂM ĐỊNH\Tool";
                a.LoginEvent         += a_LoginEvent;
                a.ButtonLoginEven    += a_ButtonLoginEven;
                if (a.ShowDialog() == DialogResult.OK)
                {
                    Global.StrMachine    = a.StrMachine;
                    Global.StrUserWindow = a.StrUserWindow;
                    Global.StrIpAddress  = a.StrIpAddress;
                    Global.StrUsername   = a.StrUserName;
                    Global.StrBatch      = a.StrBatch;
                    Global.StrRole       = a.StrRole;
                    Global.Strtoken      = a.Token;
                    frm_Main frMain = new frm_Main();

                    if (frMain.ShowDialog() == DialogResult.Yes)
                    {
                        frMain.Close();
                        temp = true;
                    }
                }
            }while (temp);
        }
Пример #3
0
 private void btn_Back_Click(object sender, EventArgs e)
 {
     Form frm_Main = new frm_Main(permissions);
     frm_Main.StartPosition = FormStartPosition.CenterScreen;
     Program.setForm(frm_Main);
     this.Close();
 }
Пример #4
0
 public PollingThread(frm_Main _form, String _myName, TcpClient _clientSocket, IntPtr _Handle)
 {
     clientSocket = _clientSocket;
     myName = _myName;
     form = _form;
     Handle = _Handle;
 }
Пример #5
0
        private void btn_Demo_Click(object sender, EventArgs e)
        {
            Hide();
            frm_Main Main = new frm_Main();

            Main.combo_Users.SelectedValue = 1;
            Main.Demo = true;
            Main.Show();
        }
Пример #6
0
        public FRM_Currency(frm_Main main)
        {
            InitializeComponent();
            Main = main;

            dt_Currency = Main.ds.Tables[35].Clone();
            foreach (DataRow dr in Main.ds.Tables[35].Rows)
            {
                dt_Currency.Rows.Add(dr.ItemArray);
            }
        }
Пример #7
0
 private void btn_Login_Click(object sender, EventArgs e)
 {
     // Role Id Reffers either a user is a customer or Chef
     if (cmb_RoleID.SelectedIndex < 0)
     {
         MessageBox.Show("Please Select Role", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         Main.RoleID = int.Parse(cmb_RoleID.SelectedValue.ToString());
         if (txt_Username.Text != "")
         {
             if (txt_Password.Text != "")
             {
                 if (Main.CheckUserName(txt_Username.Text) == true)
                 {
                     if (Main.checkPassword(txt_Username.Text, txt_Password.Text) == true)
                     {
                         Main.UserName = txt_Username.Text;
                         // I will get the UserID coresponding to the user name from the database
                         String sUserId = SQL.ScalarQuery("Select L_ID from login where L_Username = '******'");
                         int    id;
                         //Since the id is an int a simple test is performed to convert the string to int
                         if (int.TryParse(sUserId, out id))
                         {
                             Main.UserID = id;
                         }
                         // The login form will disappear
                         this.Hide();
                         // Main form (Home) will appear
                         var NEW = new frm_Main();
                         NEW.ShowDialog();
                     }
                     else
                     {
                         MessageBox.Show("Invalid Password", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Invalid Username", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                 }
             }
             else
             {
                 MessageBox.Show("Please Enter Password", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
         }
         else
         {
             MessageBox.Show("Please Enter UserName", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
     }
 }
Пример #8
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text == "" || txtPassword.Text == "")
            {
                MessageBox.Show("Please enter login credentials", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                try
                {
                    var user = new User();
                    user.UserName = txtUsername.Text;
                    user.Password = txtPassword.Text;

                    var record = UserDataAccess.findByUserId(user);

                    if (record == null)
                    {
                        MessageBox.Show("User-ID not found.Please enter login credentials", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    else
                    {
                        // check if user profile is inactive
                        if (record.IsRemoved == true)
                        {
                            MessageBox.Show("Inactive user profile", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            // check for the password
                            if (record.Password == txtPassword.Text)
                            {
                                // show home form
                                var role     = record.Role;
                                var userName = record.UserName;

                                var main = new frm_Main(userName, role);
                                main.Show();
                                this.Hide();
                            }
                            else
                            {
                                MessageBox.Show("Incorrect password.Please enter login credentials", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #9
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            BonusSkins.Register();
            SkinManager.EnableFormSkins();
            UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");
            //Application.Run(new frm_CreateBatch());

            bool temp;

            do
            {
                temp = false;
                Frm_Login a = new Frm_Login();
                a.lb_programName.Text = "\n           Dự Án JEMS";
                a.lb_vision.Text      = "Phiên bản :";
                a.grb_1.Text          = "Thông Tin PC";
                a.lb_machine.Text     = "Tên PC :";
                a.lb_user_window.Text = "Tài khoản window:";
                a.lb_ip.Text          = "Địa chỉ IP :";
                a.grb_2.Text          = "Thông Tin Tài Khoản Đăng Nhập";
                a.lb_username.Text    = "Tên đăng nhập :";
                a.lb_password.Text    = "Mật khẩu :";
                a.lb_role.Text        = "Vai trò :";
                a.lb_date.Text        = "Ngày: ";
                a.lb_time.Text        = "Giờ: ";
                a.lb_batchno.Text     = "BatchName: ";
                a.btn_thoat.Text      = "Thoát";
                a.chb_hienthi.Text    = "Hiển Thị";
                a.chb_luu.Text        = "Lưu";
                a.lb_version.Text     = @"1.2.7";
                a.UrlUpdateVersion    = @"\\10.10.10.254\DE_Viet\2017\JEMS\Tools";
                a.LoginEvent         += a_LoginEvent;
                a.ButtonLoginEven    += a_ButtonLoginEven;
                if (a.ShowDialog() == DialogResult.OK)
                {
                    Global.StrMachine    = a.StrMachine;
                    Global.StrUserWindow = a.StrUserWindow; Global.StrIpAddress = a.StrIpAddress;
                    Global.StrUsername   = a.StrUserName;
                    Global.StrBatch      = a.StrBatch;
                    Global.StrRole       = a.StrRole;
                    Global.Strtoken      = a.Token;
                    frm_Main f = new frm_Main();
                    if (f.ShowDialog() == DialogResult.Yes)
                    {
                        f.Close();
                        temp = true;
                    }
                }
            }while (temp);
        }
Пример #10
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            BonusSkins.Register();
            SkinManager.EnableFormSkins();
            UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");
            //Application.Run(new FrmTienDo());
            if (new frm_ChangeServer().ShowDialog() != DialogResult.OK)
            {
                return;
            }
            bool temp = false;

            do
            {
                temp = false;

                frmLogin frLogin = new frmLogin();
                if (frLogin.ShowDialog() == DialogResult.OK)
                {
                    if (Global.StrCity == "CityS")
                    {
                        BaoCaoLuonng2017.Global.StrMachine    = Global.StrPcName;
                        BaoCaoLuonng2017.Global.StrUserWindow = Global.StrDomainName;
                        BaoCaoLuonng2017.Global.StrIpAddress  = "";
                        BaoCaoLuonng2017.Global.StrUsername   = Global.StrUserName;
                        BaoCaoLuonng2017.Global.StrBatch      = Global.StrBatch;
                        BaoCaoLuonng2017.Global.StrRole       = Global.StrRole;
                        BaoCaoLuonng2017.Global.Strtoken      = Global.Token;
                        BaoCaoLuonng2017.Global.StrCity       = Global.StrCity;
                        BaoCaoLuonng2017.MyForm.frm_Main fm = new BaoCaoLuonng2017.MyForm.frm_Main();
                        if (fm.ShowDialog() == DialogResult.Yes)
                        {
                            fm.Close();
                            frLogin.txt_username_TextChanged(null, null);
                            temp = true;
                        }
                    }
                    else
                    {
                        frm_Main frMain = new frm_Main();
                        if (frMain.ShowDialog() == DialogResult.Yes)
                        {
                            frMain.Close();
                            temp = true;
                        }
                    }
                }
            }while (temp);
        }
Пример #11
0
        private void frm_Termin_FormClosed(object sender, FormClosedEventArgs e)
        {
            frm_Main formMain = frm_Main.getMainForm;

            foreach (CheckBox checkBox in formMain.fLP_Kalender.Controls)
            {
                checkBox.Checked = false;
            }
            foreach (CheckBox checkBox in formMain.fLP_Kalender.Controls)
            {
                checkBox.Checked = true;
            }
        }
Пример #12
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.Server   = textBox_Server.Text;
            Properties.Settings.Default.DataBase = textBox_DataBase.Text;
            Properties.Settings.Default.Mode     = radio_Windows.Checked == true ? "Windows" : "SQL";
            Properties.Settings.Default.ID       = textBox_ID.Text;
            Properties.Settings.Default.Password = textBox_Password.Text;

            frm_Main Main = new frm_Main();

            Properties.Settings.Default.Save();
            Main.Show();
            Hide();
        }
Пример #13
0
        public FRM_CC(frm_Main main)
        {
            InitializeComponent();
            Main = main;

            dt_branches = Main.dt_Branches.Clone();
            foreach (DataRow dr in Main.dt_Branches.Rows)
            {
                dt_branches.Rows.Add(dr.ItemArray);
            }

            combo_cc_branche.DataSource    = dt_branches;
            combo_cc_branche.SelectedValue = -1;
        }
Пример #14
0
        public FRM_Branches(frm_Main main)
        {
            InitializeComponent();
            Main = main;

            //Fill Branches DGV
            DGV_Branches.AutoGenerateColumns = false;
            dt_Branches             = BS.Select_All_Branches();
            DGV_Branches.DataSource = dt_Branches;

            //Fill Stores DGV
            DGV_Stores.AutoGenerateColumns = false;
            dt_Stores             = BS.Select_All_Stores();
            DGV_Stores.DataSource = dt_Stores;
        }
Пример #15
0
        private void btn_Run_Click(object sender, EventArgs e)
        {
            if (txt_Run.Text.Length != 6)
            {
                return;
            }

            int q = (Convert.ToInt32(txt_Authorization.Text.Substring(1, 1)) * 5);
            int w = (Convert.ToInt32(txt_Authorization.Text.Substring(2, 1)) * 4);
            int t = (Convert.ToInt32(txt_Authorization.Text.Substring(3, 1)) * 8);
            int r = (Convert.ToInt32(txt_Authorization.Text.Substring(4, 1)) * 6);


            string txt     = txt_Run.Text.Substring(0, 4);
            int    AddDays = Convert.ToInt32(txt_Run.Text.Substring(4, 2));
            string run     = q.ToString().Substring(0, 1) + w.ToString().Substring(0, 1) + t.ToString().Substring(0, 1) + r.ToString().Substring(0, 1);

            if (AddDays == 38)
            {
                AddDays = 3650;
            }
            else if (AddDays > 70)
            {
                AddDays = 70;
            }

            if (txt == run)
            {
                string i = Encrypt(id);
                //File.WriteAllText(path,i);
                Properties.Settings.Default.ID        = i;
                Properties.Settings.Default.d         = Encrypt(ExpireDate(AddDays));
                Properties.Settings.Default.LoginUser = "******";
                Properties.Settings.Default.Save();

                Hide();
                frm_Main Main = new frm_Main();
                Main.Show();
            }
            else
            {
                Application.Exit();
            }
        }
Пример #16
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            if (cmb_CompanyName.SelectedIndex < 0)
            {
                MessageBox.Show("Please Select Company", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                Main.CompanyID = int.Parse(cmb_CompanyName.SelectedValue.ToString());
                if (txt_Username.Text != "")
                {
                    if (txt_Password.Text != "")
                    {
                        if (Main.CheckUserName(txt_Username.Text) == true)
                        {
                            if (Main.checkPassword(txt_Username.Text, txt_Password.Text) == true)
                            {
                                Main.UserName = txt_Username.Text;

                                this.Hide();
                                var NEW = new frm_Main();
                                NEW.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("Invalid Password", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Invalid Username", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please Enter Password", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
                else
                {
                    MessageBox.Show("Please Enter UserName", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
Пример #17
0
        //启动分析应用系统
        private void StartDAS()
        {
            try
            {
                statusTxt = "正在初始化系统...";
                backgroundWorker.ReportProgress(10);

                statusTxt = "正在加载系统框架...";
                MainFrm   = new frm_Main();
                backgroundWorker.ReportProgress(20);
                Thread.Sleep(100);

                MainFrm.InitForm();
                backgroundWorker.ReportProgress(50);
                Thread.Sleep(100);

                statusTxt = "正在加载信息树...";
                MainFrm.InitTree();
                backgroundWorker.ReportProgress(60);
                Thread.Sleep(100);

                statusTxt = "正在加载列表数据...";
                MainFrm.InitCombobox();
                backgroundWorker.ReportProgress(70);
                Thread.Sleep(100);

                statusTxt = "正在设置界面风格...";
                MainFrm.InitStyle();
                backgroundWorker.ReportProgress(80);
                Thread.Sleep(100);

                statusTxt = "系统初始化成功...";
                backgroundWorker.ReportProgress(100);
                Thread.Sleep(100);

                backgroundWorker_RunWorkerCompleted(null, null);
            }
            catch (Exception excep)
            {
                XtraMessageBox.Show("启动应用程序出错," + excep.Message + ",请与系统管理员联系!", "出错提示", MessageBoxButtons.OK, MessageBoxIcon.Error);

                updateStatus("准备登录");
            }
        }
Пример #18
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            if (checkRemember.Checked)
            {
                Properties.Settings.Default.username = txt_user.Text;
                Properties.Settings.Default.password = txt_pass.Text;
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default.username = string.Empty;
                Properties.Settings.Default.password = string.Empty;
                Properties.Settings.Default.Save();
            }
            var username = txt_user.Text;
            var password = txt_pass.Text;

            if (username.Equals(""))
            {
                MessageBox.Show("Hãy Nhập Tài Khoản", "Thông Báo");
            }
            else if (password.Equals(""))
            {
                MessageBox.Show("Hãy Nhập Mật Khẩu", "Thông Báo");
            }
            else
            {
                string sql    = "select name from Account where username ='******' and password ='******'";
                var    result = db.DocBang(sql);
                if (result.Rows.Count > 0)
                {
                    this.Hide();
                    var      user = (string)result.Rows[0]["name"];
                    frm_Main frm  = new frm_Main(user);
                    frm.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Tài khoản hoặc mật khẩu không đúng!!!", "Thông Báo");
                }
            }
        }
Пример #19
0
        public FRM_ACC(frm_Main main)
        {
            InitializeComponent();
            Main       = main;
            ACC_Proper = Main.ds.Tables[25];
            com_ACC_Proper_Name.DataSource = ACC_Proper;

            dv_acc = new DataView(Main.ds.Tables[6]);
            dv_cc1 = new DataView(Main.ds.Tables[3]);
            dv_cc2 = new DataView(Main.ds.Tables[3]);

            com_Parent_ACC.DataSource    = dv_acc;
            com_Parent_ACC.SelectedValue = -1;

            com_CC1.DataSource    = dv_cc1;
            com_CC1.SelectedValue = -1;

            com_CC2.DataSource    = dv_cc2;
            com_CC2.SelectedValue = -1;
        }
Пример #20
0
        public FRM_Customer(frm_Main main)
        {
            InitializeComponent();
            Main = main;
            DGV.AutoGenerateColumns = false;

            dt_Cust = Cust.Select();

            dt_acc_cust = Main.dt_ACC.Clone();
            foreach (DataRow dr in Main.dt_ACC.Rows)
            {
                if (dr["ACC_Proper_ID"].ToString() == "1")
                {
                    dt_acc_cust.Rows.Add(dr.ItemArray);
                }
            }
            com_ACC_Name.DataSource    = dt_acc_cust;
            com_ACC_Name.SelectedValue = -1;

            DGV.CurrentCell = null;
        }
Пример #21
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            BL.BL.Users users = new BL.BL.Users();

            users.Name     = txt_Name.Text;
            users.Password = txt_Password.Text;

            DataTable dt = new DataTable();

            dt = users.Select();

            foreach (DataRow r in dt.Rows)
            {
                if ((r["Email"].ToString() == users.Name || r["Mobile"].ToString() == txt_Name.Text.Trim()) && r["Password"].ToString() == users.Password)
                {
                    Hide();
                    string c = CheckAth();
                    if (c == "OK")
                    {
                        frm_Main Main = new frm_Main();
                        UserID = Convert.ToInt32(r["ID"]);
                        Main.combo_Users.SelectedValue = UserID;
                        Main.Show();
                        Properties.Settings.Default.LoginUser = txt_Name.Text;
                        Properties.Settings.Default.Save();
                        return;
                    }
                    else
                    {
                        frm_PreventNo p = new frm_PreventNo();
                        p.UserID = Convert.ToInt16(r["ID"]);
                        p.Case   = c;
                        p.ShowDialog();
                        return;
                    }
                }
            }
            MessageBox.Show("أسم المستخدم أو كلمة المرور غير صحيحة", "خطأ في بيانات الدخول", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }
Пример #22
0
        public FRM_Ven(frm_Main main)
        {
            InitializeComponent();
            Main = main;

            dt_Ven = Main.ds.Tables[9].Clone();
            foreach (DataRow dr in Main.ds.Tables[9].Rows)
            {
                dt_Ven.Rows.Add(dr.ItemArray);
            }

            dt_acc_ven = Main.ds.Tables[6].Clone();
            foreach (DataRow dr in Main.ds.Tables[6].Rows)
            {
                if (dr["ACC_Proper_ID"].ToString() == "2")
                {
                    dt_acc_ven.Rows.Add(dr.ItemArray);
                }
            }
            com_ACC_Name.DataSource    = dt_acc_ven;
            com_ACC_Name.SelectedValue = -1;
        }
        private void bt_dangnhap_Click(object sender, EventArgs e)
        {
            DataTable dt = dangNhapModel.check_TaiKhoan(txtTenDangNhap.Text,txtMatKhau.Text);

            try
            {
                if (txtTenDangNhap.Text == "")
                {
                    MessageBox.Show("Tài khoản chưa được nhập");
                    txtTenDangNhap.Focus();
                }
                else if (txtMatKhau.Text == "")
                {
                    MessageBox.Show("Mật khẩu chưa được nhập");
                    txtMatKhau.Focus();
                }
                else if (txtTenDangNhap.Text.Trim() != dt.Rows[0][0].ToString() && txtMatKhau.Text == dt.Rows[0][1].ToString())
                {
                    MessageBox.Show("Tên đăng nhập không đúng");
                    txtTenDangNhap.Focus();
                }
                else if (txtTenDangNhap.Text.Trim() == dt.Rows[0][0].ToString() && txtMatKhau.Text != dt.Rows[0][1].ToString())
                {
                    MessageBox.Show("Mật khẩu không đúng");
                    txtMatKhau.Focus();
                }
                else if (txtTenDangNhap.Text.Trim() == dt.Rows[0][0].ToString() && txtMatKhau.Text == dt.Rows[0][1].ToString())
                {
                    frm_Main main = new frm_Main();
                    main.Show();
                    this.Hide();
                }
            }
            catch
            {
                MessageBox.Show("Tên đăng nhập và Mật khẩu không đúng");
            }
        }
Пример #24
0
        private void bntdangnhap_Click(object sender, EventArgs e)
        {
            SqlParameter para1   = new SqlParameter("@taikhoan", txtuser.Text);
            SqlParameter para2   = new SqlParameter("@matkhau", txtpass.Text);
            DataTable    dulieu  = dt.sqlLayDuLieu("PSP_NhanVien_test", para1, para2);
            SqlParameter para3   = new SqlParameter("@TaiKhoan", txtuser.Text);
            DataTable    dulieu1 = dt.sqlLayDuLieu("PSP_NhanVien_Loai", para3);



            if (dulieu.Rows.Count < 1)
            {
                MessageBox.Show("Tài khoản không đúng !");
            }
            else
            {
                quyen = dulieu1.Rows[0]["LoaiTK"].ToString();
                tk    = txtuser.Text;
                frm_Main frm = new frm_Main();
                frm.Show();
                this.Hide();
            }
        }
Пример #25
0
 public PollingThread(frm_Main _form, String _myName, TcpClient _clientSocket)
 {
     clientSocket = _clientSocket;
     myName = _myName;
     form = _form;
 }
Пример #26
0
 public Controller(frm_Main _main)
 {
     InitializeComponent();
     Dock = DockStyle.Fill;
     main = _main;
 }
Пример #27
0
        public FRM_rep(frm_Main main)
        {
            InitializeComponent();
            Main = main;

            btn_Display.Image = Main.imageList48.Images["display_48.png"];

            dtp         = new DateTimePicker();
            dtp.Format  = DateTimePickerFormat.Short;
            dtp.Visible = false;
            dtp.Width   = 120;
            DGV_1.Controls.Add(dtp);
            dtp.ValueChanged += this.dtp_Value_Changed;

            Rep_TABLE_NAME   = Main.Rep_TABLE_NAME;
            Rep_TABLE_SCHEMA = Main.Rep_TABLE_SCHEMA;

            dt_Rep_Info = rep.Select_Rep_Info(Rep_TABLE_NAME, Rep_TABLE_SCHEMA);
            foreach (DataRow r in dt_Rep_Info.Rows)
            {
                list_Back.Items.Add(r[0].ToString());
            }


            dt_g     = rep.Select_Rep("select * from Rep");
            dt_Rep_D = rep.Select_Rep("select * from Rep_D");
            dt_g.DefaultView.RowFilter     = string.Format("Rep_View = '" + Rep_TABLE_NAME + "' and User_ID = " + Main.combo_Users.SelectedValue.ToString());
            com_RepGenerator.DataSource    = dt_g;
            com_RepGenerator.SelectedValue = -1;
            com_Fields.DataSource          = dt_Rep_Info;

            if (com_RepGenerator.SelectedValue == null)
            {
                dt_Rep_D.DefaultView.RowFilter = string.Format("Rep_ID = -1 ");
            }
            else
            {
                dt_Rep_D.DefaultView.RowFilter = string.Format("Rep_ID = " + com_RepGenerator.SelectedValue.ToString());
            }
            DGV_1.AutoGenerateColumns = false;

            foreach (DataRow dr in dt_Rep_Info.Rows)
            {
                (DGV_1.Columns[0] as DataGridViewComboBoxColumn).Items.Add(dr[0].ToString());
            }


            Temp_dgv         = table(1);
            DGV_1.DataSource = null;
            foreach (DataRow row in Temp_dgv.Rows)
            {
                DGV_1.Rows.Add();
                DGV_1.CurrentCell = DGV_1.Rows[0].Cells[0];

                DGV_1.CurrentRow.Cells[0].Value = row[0].ToString();
                DGV_1.CurrentRow.Cells[1].Value = row[1].ToString();
                DGV_1.CurrentRow.Cells[2].Value = row[2].ToString();
                DGV_1.CurrentRow.Cells[3].Value = row[3].ToString();
                DGV_1.CurrentRow.Cells[4].Value = row[4].ToString();
                DGV_1.CurrentRow.Cells[5].Value = row[5].ToString();
                DGV_1.CurrentRow.Cells[6].Value = row[6].ToString();
            }
            DGV_1.AllowUserToAddRows = true;
        }
Пример #28
0
 public BLL_Main(frm_Main _f_Main)
 {
     f_Main = _f_Main;
 }
Пример #29
0
 public PiClient(frm_Main _main)
 {
     InitializeComponent();
     Dock = DockStyle.Fill;
     main = _main;
 }
Пример #30
0
        private void button_Select_Click(object sender, RoutedEventArgs e)
        {
            if (Patient_DataTable.Rows.Count > 0 && datagrid_Patient.SelectedIndex >= 0)
            {
                Patient_New.FileID     = Patient_DataTable.Rows[datagrid_Patient.SelectedIndex]["FileID"].ToString();
                Patient_New.PatientID  = Patient_DataTable.Rows[datagrid_Patient.SelectedIndex]["PatientID"].ToString();
                Patient_New.Name       = Patient_DataTable.Rows[datagrid_Patient.SelectedIndex]["Name"].ToString();
                Patient_New.Birthday   = Patient_DataTable.Rows[datagrid_Patient.SelectedIndex]["Birthday"].ToString();
                Patient_New.Sex        = Patient_DataTable.Rows[datagrid_Patient.SelectedIndex]["Sex"].ToString();
                Patient_New.Address    = Patient_DataTable.Rows[datagrid_Patient.SelectedIndex]["Address"].ToString();
                Patient_New.Tele       = Patient_DataTable.Rows[datagrid_Patient.SelectedIndex]["Tele"].ToString();
                Patient_New.IdentifyID = Patient_DataTable.Rows[datagrid_Patient.SelectedIndex]["IdentifyID"].ToString();
                Patient_New.Memo       = Patient_DataTable.Rows[datagrid_Patient.SelectedIndex]["Memo"].ToString();

                if (Record_DataTable.Rows.Count > 0)
                {
                    string sTmp = "";
                    Record_New = new MyData.CheckRecord_Struct[Record_DataTable.Rows.Count];
                    for (int i = 0; i < Record_DataTable.Rows.Count; i++)
                    {
                        Record_New[i].RecordID  = Record_DataTable.Rows[i]["RecordID"].ToString();
                        Record_New[i].FileID    = Record_DataTable.Rows[i]["FileID"].ToString();
                        Record_New[i].CheckTime = Record_DataTable.Rows[i]["CheckTime"].ToString();
                        Record_New[i].Doctor    = Record_DataTable.Rows[i]["Doctor"].ToString();
                        Record_New[i].CheckInfo = Record_DataTable.Rows[i]["CheckInfo"].ToString();

                        sTmp = System.Environment.CurrentDirectory + "\\Data\\" + Record_New[i].FileID.Trim() + "\\";
                        Record_New[i].SmallPict  = sTmp + "Small\\" + Record_DataTable.Rows[i]["SmallPict"].ToString();
                        Record_New[i].BigPict    = sTmp + "Big\\" + Record_DataTable.Rows[i]["BigPict"].ToString();
                        Record_New[i].SelectPict = "";
                    }

                    iSelectRecordID = int.Parse(Record_DataTable.Rows[datagrid_Record.SelectedIndex]["RecordID"].ToString());          // 选定的检查记录的RecordID
                }
                else
                {
                    Record_New = null;
                }

                IsSelectNew = true;

                if (IsShowInput)   // 从frm_Start调用
                {
                    pfrm_Start.Show();
                    pfrm_Start.IsEnabled     = true;
                    pfrm_Start.ShowInTaskbar = true;

                    this.Hide();
                }
                else       // 从frm_Start调用
                {
                    frm_Main Frm_Main = new frm_Main();
                    Frm_Main.IsFirst     = true;
                    Frm_Main.Patient_New = Patient_New;
                    Frm_Main.Record_New  = Record_New;
                    Frm_Main.pfrm_Search = this;

                    this.ShowInTaskbar = false;
                    pfrm_Start.Hide();
                    this.Hide();

                    Frm_Main.ShowDialog();
                }
            }
            else
            {
                Patient_New = new MyData.PatientInfo_Struct();
                Record_New  = null;
                IsSelectNew = false;
            }
        }
 public frm_Settings(frm_Main main)
 {
     _main = main;
 }
Пример #32
0
        public FRM_Money_Out(frm_Main main)
        {
            InitializeComponent();
            Main = main;

            btn_Bill_Branche.Image = Main.imageList32.Images["branche_32.png"];
            btn_CC1.Image          = Main.imageList32.Images["center1_32.png"];
            btn_CC2.Image          = Main.imageList32.Images["center1_32.png"];
            btn_Bill_User.Image    = Main.imageList32.Images["user_32.png"];

            dt_ACC_Ven = Main.dt_ACC.Clone();
            foreach (DataRow dr in Main.dt_ACC.Rows)
            {
                dt_ACC_Ven.Rows.Add(dr.ItemArray);
            }
            dt_ACC_Ven.DefaultView.RowFilter = string.Format("Is_Parent=0");

            dt_branches = Main.dt_Branches.Clone();
            foreach (DataRow dr in Main.dt_Branches.Rows)
            {
                dt_branches.Rows.Add(dr.ItemArray);
            }

            dt_cc1 = Main.dt_CC.Clone();
            foreach (DataRow dr in Main.dt_CC.Rows)
            {
                dt_cc1.Rows.Add(dr.ItemArray);
            }
            dt_cc1.DefaultView.RowFilter = string.Format("CC1 = True");

            dt_cc2 = Main.dt_CC.Clone();
            foreach (DataRow dr in Main.dt_CC.Rows)
            {
                dt_cc2.Rows.Add(dr.ItemArray);
            }
            dt_cc2.DefaultView.RowFilter = string.Format("CC2 = True");

            dt_users = Main.dt_Users.Clone();
            foreach (DataRow dr in Main.dt_Users.Rows)
            {
                dt_users.Rows.Add(dr.ItemArray);
            }

            combo_Bill_User.DataSource     = Main.dt_Users;
            combo_Bill_Branches.DataSource = Main.dt_Branches;
            combo_CC1.DataSource           = Main.dt_CC;
            combo_CC2.DataSource           = Main.dt_CC;

            #region ContextMenuStrips
            // Branches
            combo_Bill_Branches.DataSource      = dt_branches;
            combo_Bill_Branches.SelectedValue   = Main.combo_Branches.SelectedValue;
            lbl_bill_Branches.Text              = combo_Bill_Branches.Text;
            contextMenuStrip_branches.ForeColor = Color.MidnightBlue;

            for (int i = 0; i < combo_Bill_Branches.Items.Count; i++)
            {
                contextMenuStrip_branches.Items.Add(combo_Bill_Branches.GetItemText(combo_Bill_Branches.Items[i]), Main.imageList16.Images["branche_16.png"]);
            }

            // CC1
            combo_CC1.DataSource           = dt_cc1;
            combo_CC1.SelectedValue        = -1;
            lbl_CC1.Text                   = combo_CC1.Text;
            btn_cc1_del.Image              = Main.imageList16.Images["close_16.png"];
            contextMenuStrip_cc1.ForeColor = Color.MidnightBlue;

            for (int i = 0; i < combo_CC1.Items.Count; i++)
            {
                contextMenuStrip_cc1.Items.Add(combo_CC1.GetItemText(combo_CC1.Items[i]), Main.imageList16.Images["center_16.png"]);
            }

            // CC2
            combo_CC2.DataSource           = dt_cc2;
            combo_CC2.SelectedValue        = -1;
            lbl_CC2.Text                   = combo_CC2.Text;
            btn_cc2_del.Image              = Main.imageList16.Images["close_16.png"];
            contextMenuStrip_cc2.ForeColor = Color.MidnightBlue;

            for (int i = 0; i < combo_CC2.Items.Count; i++)
            {
                contextMenuStrip_cc2.Items.Add(combo_CC2.GetItemText(combo_CC2.Items[i]), Main.imageList16.Images["center_16.png"]);
            }

            // Users
            combo_Bill_User.DataSource       = dt_users;
            contextMenuStrip_users.ForeColor = Color.MidnightBlue;
            for (int i = 0; i < combo_Bill_User.Items.Count; i++)
            {
                contextMenuStrip_users.Items.Add(combo_Bill_User.GetItemText(combo_Bill_User.Items[i]), Main.imageList16.Images["user_16.png"]);
            }
            #endregion
        }
Пример #33
0
 public FRM_Job_Type(frm_Main main)
 {
     InitializeComponent();
     Main = main;
     DGV_Job_Type.AutoGenerateColumns = false;
 }
Пример #34
0
        public void Add()
        {
            bool isFinished = false;
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = dbh.GetCon();

                if (table == "tbl_Appointments")
                {
                    int ID = Convert.ToInt32(combo[4].SelectedValue);
                    if (ID != 0)
                    {
                        cmd.CommandText = "INSERT INTO TBL_APPOINTMENTS(DESCRIPTION, DATE, NEXT_ACTION, ID_PROJECT, NAME) VALUES (@DESCRIPTION, @DATE, @NEXT_ACTION, @ID_PROJECT, @NAME)";
                    }
                    else
                    {
                        cmd.CommandText = "INSERT INTO TBL_APPOINTMENTS(DESCRIPTION, DATE, NEXT_ACTION, NAME) VALUES (@DESCRIPTION, @DATE, @NEXT_ACTION, @NAME)";
                    }
                    cmd.Parameters.AddWithValue("@DESCRIPTION", tb[1].Text);
                    cmd.Parameters.AddWithValue("@DATE", dtp[2].Value);
                    cmd.Parameters.AddWithValue("@NEXT_ACTION", tb[3].Text);
                    if (ID != 0)
                    {
                        cmd.Parameters.AddWithValue("@ID_PROJECT", combo[4].SelectedValue);
                    }
                    cmd.Parameters.AddWithValue("@NAME", tb[5].Text);
                }
                else if (table == "tbl_Customers")
                {
                    cmd.CommandText = "INSERT INTO TBL_CUSTOMERS (NAME, ADDRESS1, HOUSENR1, ZIP_CODE1, PLACE1, COUNTRY1, ADDRESS2, HOUSENR2, ZIP_CODE2, PLACE2, COUNTRY2, PHONE, FAX, EMAIL, POTENTIAL_PROSPECT) VALUES (@NAME, @ADDRESS1, @HOUSENR1, @ZIP_CODE1, @PLACE1, @COUNTRY1, @ADDRESS2, @HOUSENR2, @ZIP_CODE2, @PLACE2, @COUNTRY2, @PHONE, @FAX, @EMAIL, @POTENTIAL_PROSPECT)";
                    cmd.Parameters.AddWithValue("@NAME", tb[1].Text);
                    cmd.Parameters.AddWithValue("@ADDRESS1", tb[2].Text);
                    cmd.Parameters.AddWithValue("@HOUSENR1",tb[3].Text);
                    cmd.Parameters.AddWithValue("@ZIP_CODE1", tb[4].Text);
                    cmd.Parameters.AddWithValue("@PLACE1", tb[5].Text);
                    cmd.Parameters.AddWithValue("@COUNTRY1",tb[6].Text);
                    cmd.Parameters.AddWithValue("@ADDRESS2", tb[7].Text);
                    cmd.Parameters.AddWithValue("@HOUSENR2", tb[8].Text);
                    cmd.Parameters.AddWithValue("@ZIP_CODE2", tb[9].Text);
                    cmd.Parameters.AddWithValue("@PLACE2", tb[10].Text);
                    cmd.Parameters.AddWithValue("@COUNTRY2", tb[11].Text);
                    cmd.Parameters.AddWithValue("@PHONE", tb[12].Text);
                    cmd.Parameters.AddWithValue("@FAX", tb[13].Text);
                    cmd.Parameters.AddWithValue("@EMAIL", tb[14].Text);
                    cmd.Parameters.AddWithValue("@POTENTIAL_PROSPECT", combo[15].SelectedValue);
                }

                else if(table == "tbl_Invoices")
                {
                    int ID = Convert.ToInt32(combo[9].SelectedValue);

                    if (ID != 0)
                    {
                        cmd.CommandText = "INSERT INTO TBL_INVOICES ( AMOUNT, BANK_ACC_NR, GROSS_REV, LEDGER_ACC_NR, TAX_CODE, ID_PROJECT, IS_PAID, DATE, INVOICE_SENT, NAME) VALUES ( @AMOUNT, @BANK_ACC_NR, @GROSS_REV, @LEDGER_ACC_NR, @TAX_CODE, @ID_PROJECT, @IS_PAID, @DATE, @INVOICE_SENT, @NAME)";
                    }
                    else
                    {
                        cmd.CommandText = "INSERT INTO TBL_INVOICES ( AMOUNT, BANK_ACC_NR, GROSS_REV, LEDGER_ACC_NR, TAX_CODE, IS_PAID, DATE, INVOICE_SENT, NAME) VALUES ( @AMOUNT, @BANK_ACC_NR, @GROSS_REV, @LEDGER_ACC_NR, @TAX_CODE, @IS_PAID, @DATE, @INVOICE_SENT, @NAME)";
                    }

                    cmd.Parameters.AddWithValue("@AMOUNT", tb[1].Text.Replace(".", ","));
                    cmd.Parameters.AddWithValue("@BANK_ACC_NR", tb[2].Text);
                    cmd.Parameters.AddWithValue("@GROSS_REV", tb[3].Text.Replace(".", ","));
                    cmd.Parameters.AddWithValue("@LEDGER_ACC_NR", tb[4].Text);
                    cmd.Parameters.AddWithValue("@TAX_CODE", tb[5].Text);
                    cmd.Parameters.AddWithValue("@IS_PAID", checkboxState(cb[6]));
           
                    cmd.Parameters.AddWithValue("@INVOICE_SENT", checkboxState(cb[7]));
                    cmd.Parameters.AddWithValue("@DATE", dtp[8].Value);
                    if (ID != 0)
                    {
                        cmd.Parameters.AddWithValue("@ID_PROJECT", combo[9].SelectedValue);
                    }
                    cmd.Parameters.AddWithValue("@NAME", tb[10].Text);
                }

                else if (table == "tbl_Projects")
                {
                    int ID = Convert.ToInt32(combo[11].SelectedValue);

                    if (ID != 0)
                    {
                        cmd.CommandText = "INSERT INTO TBL_PROJECTS (NAME, HARDWARE, OPERATING_SYSTEM, MAINTENANCE_CONTRACT, APPLICATIONS, LIMIT, ID_CUSTOMER, IS_DONE, NR_INVOICES, BKR, CREDITWORTHY) VALUES (@NAME, @HARDWARE, @OPERATING_SYSTEM, @MAINTENANCE_CONTRACT, @APPLICATIONS, @LIMIT, @ID_CUSTOMER, @IS_DONE, @NR_INVOICES, @BKR, @CREDITWORTHY)";
                    }
                    else
                    {
                        cmd.CommandText = "INSERT INTO TBL_PROJECTS (NAME, HARDWARE, OPERATING_SYSTEM, MAINTENANCE_CONTRACT, APPLICATIONS, LIMIT, IS_DONE, NR_INVOICES, BKR, CREDITWORTHY) VALUES (@NAME, @HARDWARE, @OPERATING_SYSTEM, @MAINTENANCE_CONTRACT, @APPLICATIONS, @LIMIT, @IS_DONE, @NR_INVOICES, @BKR, @CREDITWORTHY)";

                    }
                    cmd.Parameters.AddWithValue("@NAME", tb[1].Text);
                    cmd.Parameters.AddWithValue("@HARDWARE", tb[2].Text);
                    cmd.Parameters.AddWithValue("@OPERATING_SYSTEM", tb[3].Text);
                    cmd.Parameters.AddWithValue("@MAINTENANCE_CONTRACT", checkboxState(cb[4]));
                    cmd.Parameters.AddWithValue("@APPLICATIONS", tb[5].Text);
                    cmd.Parameters.AddWithValue("@LIMIT", tb[6].Text.Replace(".", ","));
                    
                    cmd.Parameters.AddWithValue("@IS_DONE", checkboxState(cb[7]));
                    cmd.Parameters.AddWithValue("@NR_INVOICES", tb[8].Text);
                    cmd.Parameters.AddWithValue("@BKR", checkboxState(cb[9]));
                    cmd.Parameters.AddWithValue("@CREDITWORTHY", checkboxState(cb[10]));
                    if (ID != 0)
                    {
                        cmd.Parameters.AddWithValue("@ID_CUSTOMER", combo[11].SelectedValue);
                    }
                }

                dbh.OpenCon();
                cmd.ExecuteNonQuery();
                dbh.CloseCon();

                cmd.Dispose();

                MessageBox.Show("Sucessfully added this record.", "Succes!");

                isFinished = true;
            }

            catch(SqlException ex)
            {
                MessageBox.Show("One or more fields contain incorrect data." + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            finally
            {
                if (isFinished)
                {
                    dbh.CloseCon();
                    Form frm_Main = new frm_Main();
                    frm_Main.StartPosition = FormStartPosition.CenterScreen;
                    Program.setForm(frm_Main);
                    this.Close();
                }
            }
        }
Пример #35
0
 private void btn_Exit_Click(object sender, EventArgs e)
 {
     Form frm_Main = new frm_Main(permissions);
     Program.setForm(frm_Main);
     this.Close();
 }
Пример #36
0
 public FRM_Rep_Des(frm_Main main)
 {
     InitializeComponent();
     Main = main;
 }
Пример #37
0
        //saves record to database.
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                string insertQuery;
                string ID = cb_Customers.SelectedValue.ToString();

                switch (table)
                {
                    #region Appointments
                    case "tbl_Appointments":
                        TextBox A_description = Application.OpenForms["frm_Edit"].Controls["tb_description"] as TextBox;
                        DateTimePicker A_date = Application.OpenForms["frm_Edit"].Controls["dtp_date"] as DateTimePicker;
                        TextBox A_next_action = Application.OpenForms["frm_Edit"].Controls["tb_next_action"] as TextBox;
                        TextBox A_name = Application.OpenForms["frm_Edit"].Controls["tb_name"] as TextBox;
                        ComboBox A_Id_project = Application.OpenForms["frm_Edit"].Controls["combo_Id_project"] as ComboBox;

                        int convertedID = Convert.ToInt32(A_Id_project.SelectedValue);

                        dbh.OpenCon();
                        if (convertedID != 0)
                        {
                            insertQuery = "UPDATE " + table + " SET description='" + A_description.Text + "', date='" + A_date.Text + "', next_action='" + A_next_action.Text + "', ID_project='" + convertedID + "', name='" + A_name.Text + "' WHERE ID=" + ID;
                        }
                        else
                        {
                            insertQuery = "UPDATE " + table + " SET description='" + A_description.Text + "', date='" + A_date.Text + "', next_action='" + A_next_action.Text + "', ID_project=NULL, name='" + A_name.Text + "' WHERE ID=" + ID;

                        }
                        SqlCommand cmd = new SqlCommand(insertQuery, dbh.GetCon());
                        cmd.ExecuteNonQuery();

                        dbh.CloseCon();
                        MessageBox.Show("Save succesful.", "Succes!");
                        break;
                    #endregion
                    #region Customers
                    case "tbl_Customers":
                        TextBox C_name = Application.OpenForms["frm_Edit"].Controls["tb_name"] as TextBox;
                        TextBox C_address1 = Application.OpenForms["frm_Edit"].Controls["tb_address1"] as TextBox;
                        TextBox C_housenr1 = Application.OpenForms["frm_Edit"].Controls["tb_housenr1"] as TextBox;
                        TextBox C_zip_code1 = Application.OpenForms["frm_Edit"].Controls["tb_zip_code1"] as TextBox;
                        TextBox C_place1 = Application.OpenForms["frm_Edit"].Controls["tb_place1"] as TextBox;
                        TextBox C_country1 = Application.OpenForms["frm_Edit"].Controls["tb_country1"] as TextBox;
                        TextBox C_address2 = Application.OpenForms["frm_Edit"].Controls["tb_address2"] as TextBox;
                        TextBox C_housenr2 = Application.OpenForms["frm_Edit"].Controls["tb_housenr2"] as TextBox;
                        TextBox C_zip_code2 = Application.OpenForms["frm_Edit"].Controls["tb_zip_code2"] as TextBox;
                        TextBox C_place2 = Application.OpenForms["frm_Edit"].Controls["tb_place2"] as TextBox;
                        TextBox C_country2 = Application.OpenForms["frm_Edit"].Controls["tb_country2"] as TextBox;
                        TextBox C_phone = Application.OpenForms["frm_Edit"].Controls["tb_phone"] as TextBox;
                        TextBox C_fax = Application.OpenForms["frm_Edit"].Controls["tb_fax"] as TextBox;
                        TextBox C_email = Application.OpenForms["frm_Edit"].Controls["tb_email"] as TextBox;
                        ComboBox C_potential_prospect = Application.OpenForms["frm_Edit"].Controls["combo_potential_prospect"] as ComboBox;

                        dbh.OpenCon();

                        insertQuery = "UPDATE " + table + " SET name='" + C_name.Text + "', address1='" + C_address1.Text + "', housenr1='" + C_housenr1.Text + "', zip_code1='" + C_zip_code1.Text + "', place1='" + C_place1.Text + "', country1='" + C_country1.Text + "', address2='" + C_address2.Text + "', housenr2='" + C_housenr2.Text + "', zip_code2='" + C_zip_code2.Text + "', place2='" + C_place2.Text + "', country2='" + C_country2.Text + "', phone='" + C_phone.Text + "', fax='" + C_fax.Text + "', email='" + C_email.Text + "', potential_prospect='" + C_potential_prospect.SelectedValue + "' WHERE ID=" + ID;
                        cmd = new SqlCommand(insertQuery, dbh.GetCon());
                        cmd.ExecuteNonQuery();

                        dbh.CloseCon();
                        MessageBox.Show("Save succesful.", "Succes!");
                        break;
                    #endregion
                    #region Invoices
                    case "tbl_Invoices":
                        TextBox I_amount = Application.OpenForms["frm_Edit"].Controls["tb_amount"] as TextBox;
                        TextBox I_bank_acc_nr = Application.OpenForms["frm_Edit"].Controls["tb_bank_acc_nr"] as TextBox;
                        TextBox I_gross_rev = Application.OpenForms["frm_Edit"].Controls["tb_gross_rev"] as TextBox;
                        TextBox I_ledger_acc_nr = Application.OpenForms["frm_Edit"].Controls["tb_ledger_acc_nr"] as TextBox;
                        TextBox I_tax_code = Application.OpenForms["frm_Edit"].Controls["tb_tax_code"] as TextBox;
                        CheckBox I_is_paid = Application.OpenForms["frm_Edit"].Controls["cb_is_paid"] as CheckBox;
                        CheckBox I_invoice_sent = Application.OpenForms["frm_Edit"].Controls["cb_invoice_sent"] as CheckBox;
                        DateTimePicker I_date = Application.OpenForms["frm_Edit"].Controls["dtp_date"] as DateTimePicker;
                        ComboBox I_id_project = Application.OpenForms["frm_Edit"].Controls["combo_Id_project"] as ComboBox;
                        TextBox I_name = Application.OpenForms["frm_Edit"].Controls["tb_name"] as TextBox;

                        int isPaidIsChecked, invoiceSendIsChecked;

                        convertedID = Convert.ToInt32(I_id_project.SelectedValue);

                        if (I_is_paid.Checked == true)
                        {
                            isPaidIsChecked = 1;
                        }
                        else { isPaidIsChecked = 0; }

                        if (I_invoice_sent.Checked == true)
                        {
                            invoiceSendIsChecked = 1;
                        }
                        else { invoiceSendIsChecked = 0; }

                        dbh.OpenCon();

                        I_amount.Text = I_amount.Text.Replace(",", ".");
                        I_gross_rev.Text = I_gross_rev.Text.Replace(",", ".");

                        if (convertedID != 0)
                        {
                            insertQuery = "UPDATE " + table + " SET amount='" + I_amount.Text + "', bank_acc_nr='" + I_bank_acc_nr.Text + "', gross_rev='" + I_gross_rev.Text + "', ledger_acc_nr='" + I_ledger_acc_nr.Text + "', tax_code='" + I_tax_code.Text + "', is_paid='" + isPaidIsChecked + "', invoice_sent='" + invoiceSendIsChecked + "', date='" + I_date.Text + "', Id_project=" + CheckIDNull(convertedID) + ", name='" + I_name.Text + "' WHERE ID=" + ID;
                        }
                        else
                        {
                            insertQuery = "UPDATE " + table + " SET amount='" + I_amount.Text + "', bank_acc_nr='" + I_bank_acc_nr.Text + "', gross_rev='" + I_gross_rev.Text + "', ledger_acc_nr='" + I_ledger_acc_nr.Text + "', tax_code='" + I_tax_code.Text + "', is_paid='" + isPaidIsChecked + "', invoice_sent='" + invoiceSendIsChecked + "', date='" + I_date.Text + "', Id_project=NULL, name='" + I_name.Text + "' WHERE ID=" + ID;
                        }

                        cmd = new SqlCommand(insertQuery, dbh.GetCon());
                        cmd.ExecuteNonQuery();

                        dbh.CloseCon();
                        MessageBox.Show("Save succesful.", "Succes!");

                        break;
                    #endregion
                    #region Projects
                    case "tbl_Projects":
                        TextBox P_name = Application.OpenForms["frm_Edit"].Controls["tb_name"] as TextBox;
                        TextBox P_hardware = Application.OpenForms["frm_Edit"].Controls["tb_hardware"] as TextBox;
                        TextBox P_os = Application.OpenForms["frm_Edit"].Controls["tb_operating_system"] as TextBox;
                        CheckBox P_mc = Application.OpenForms["frm_Edit"].Controls["cb_maintenance_contract"] as CheckBox;
                        TextBox P_applications = Application.OpenForms["frm_Edit"].Controls["tb_applications"] as TextBox;
                        TextBox P_limit = Application.OpenForms["frm_Edit"].Controls["tb_limit"] as TextBox;
                        CheckBox P_isdone = Application.OpenForms["frm_Edit"].Controls["cb_is_done"] as CheckBox;
                        TextBox P_invoices = Application.OpenForms["frm_Edit"].Controls["tb_nr_invoices"] as TextBox;
                        CheckBox P_bkr = Application.OpenForms["frm_Edit"].Controls["cb_BKR"] as CheckBox;
                        CheckBox P_credit = Application.OpenForms["frm_Edit"].Controls["cb_creditworthy"] as CheckBox;
                        ComboBox P_id_customer = Application.OpenForms["frm_Edit"].Controls["combo_Id_customer"] as ComboBox;

                        convertedID = Convert.ToInt32(P_id_customer.SelectedValue);

                        int mcIsChecked, isDoneIsChecked, bkrIsChecked, creditIsChecked;

                        #region If Statements
                        if (P_mc.Checked == true)
                        {
                            mcIsChecked = 1;
                        }
                        else { mcIsChecked = 0; }

                        if (P_isdone.Checked == true)
                        {
                            isDoneIsChecked = 1;
                        }
                        else { isDoneIsChecked = 0; }

                        if (P_bkr.Checked == true)
                        {
                            bkrIsChecked = 1;
                        }
                        else { bkrIsChecked = 0; }

                        if (P_credit.Checked == true)
                        {
                            creditIsChecked = 1;
                        }
                        else { creditIsChecked = 0; }
                        #endregion

                        dbh.OpenCon();

                        P_limit.Text = P_limit.Text.Replace(",", ".");

                        if (convertedID != 0)
                        {
                            insertQuery = "UPDATE " + table + " SET name='" + P_name.Text + "', hardware='" + P_hardware.Text + "', operating_system='" + P_os.Text + "', maintenance_contract='" + mcIsChecked + "', applications='" + P_applications.Text + "', limit='" + P_limit.Text + "', is_done='" + isDoneIsChecked + "', nr_invoices='" + P_invoices.Text + "', BKR='" + bkrIsChecked + "', creditworthy='" + creditIsChecked + "', Id_customer='" + CheckIDNull(convertedID) + "' WHERE ID=" + ID;
                        }
                        else
                        {
                            insertQuery = "UPDATE " + table + " SET name='" + P_name.Text + "', hardware='" + P_hardware.Text + "', operating_system='" + P_os.Text + "', maintenance_contract='" + mcIsChecked + "', applications='" + P_applications.Text + "', limit='" + P_limit.Text + "', is_done='" + isDoneIsChecked + "', nr_invoices='" + P_invoices.Text + "', BKR='" + bkrIsChecked + "', creditworthy='" + creditIsChecked + "', Id_customer=NULL WHERE ID=" + ID;
                        }

                        cmd = new SqlCommand(insertQuery, dbh.GetCon());
                        cmd.ExecuteNonQuery();

                        dbh.CloseCon();
                        MessageBox.Show("Save succesful.", "Succes!");

                        break;
                    #endregion
                }
                dbh.CloseCon();
                Form frm_Main = new frm_Main(permissions);
                frm_Main.StartPosition = FormStartPosition.CenterScreen;
                Program.setForm(frm_Main);
                this.Close();
            }
            catch
            {
                MessageBox.Show("One or more fields contain incorrect data.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #38
0
        public FRM_BS(frm_Main main)
        {
            InitializeComponent();
            Main = main;

            btn_Bill_Branche.Image = Main.imageList32.Images["branche_32.png"];
            btn_CC1.Image          = Main.imageList32.Images["center1_32.png"];
            btn_CC2.Image          = Main.imageList32.Images["center1_32.png"];

            button_Display.Image = Main.imageList48.Images["display_48.png"];

            dt_branches = Main.dt_Branches.Clone();
            foreach (DataRow dr in Main.dt_Branches.Rows)
            {
                dt_branches.Rows.Add(dr.ItemArray);
            }

            dt_cc1 = Main.dt_CC.Clone();
            foreach (DataRow dr in Main.dt_CC.Rows)
            {
                dt_cc1.Rows.Add(dr.ItemArray);
            }
            dt_cc1.DefaultView.RowFilter = string.Format("CC1 = True");

            dt_cc2 = Main.dt_CC.Clone();
            foreach (DataRow dr in Main.dt_CC.Rows)
            {
                dt_cc2.Rows.Add(dr.ItemArray);
            }
            dt_cc2.DefaultView.RowFilter = string.Format("CC2 = True");

            DGV.AutoGenerateColumns = false;
            DGV.DataSource          = dt_BS;


            #region ContextMenuStrips
            // Branches
            combo_Bill_Branches.DataSource      = dt_branches;
            lbl_bill_Branches.Text              = combo_Bill_Branches.Text;
            btn_branche_del.Image               = Main.imageList16.Images["close_16.png"];
            contextMenuStrip_branches.ForeColor = Color.MidnightBlue;

            for (int i = 0; i < combo_Bill_Branches.Items.Count; i++)
            {
                contextMenuStrip_branches.Items.Add(combo_Bill_Branches.GetItemText(combo_Bill_Branches.Items[i]), Main.imageList16.Images["branche_16.png"]);
            }

            // CC1
            combo_CC1.DataSource           = dt_cc1;
            combo_CC1.SelectedValue        = -1;
            lbl_CC1.Text                   = combo_CC1.Text;
            btn_cc1_del.Image              = Main.imageList16.Images["close_16.png"];
            contextMenuStrip_cc1.ForeColor = Color.MidnightBlue;

            for (int i = 0; i < combo_CC1.Items.Count; i++)
            {
                contextMenuStrip_cc1.Items.Add(combo_CC1.GetItemText(combo_CC1.Items[i]), Main.imageList16.Images["center_16.png"]);
            }

            // CC2
            combo_CC2.DataSource           = dt_cc2;
            combo_CC2.SelectedValue        = -1;
            lbl_CC2.Text                   = combo_CC2.Text;
            btn_cc2_del.Image              = Main.imageList16.Images["close_16.png"];
            contextMenuStrip_cc2.ForeColor = Color.MidnightBlue;

            for (int i = 0; i < combo_CC2.Items.Count; i++)
            {
                contextMenuStrip_cc2.Items.Add(combo_CC2.GetItemText(combo_CC2.Items[i]), Main.imageList16.Images["center_16.png"]);
            }
            #endregion
            combo_Bill_Branches.SelectedValue = Main.combo_Branches.SelectedValue;
        }
Пример #39
0
        public void LogIn(string user, string pass)
        {
            user = tb_Username.Text;
            pass = tb_Password.Text;

            string query = "SELECT * FROM TBL_LOGIN WHERE USERNAME = @USERNAME AND PASSWORD = @PASSWORD";

            dbh.OpenCon();

            SqlCommand com = new SqlCommand(query, dbh.GetCon());
            com.Parameters.Add(new SqlParameter("@USERNAME", user));
            com.Parameters.Add(new SqlParameter("@PASSWORD", pass));

            SqlDataReader reader = com.ExecuteReader();

            while (reader.Read())
            {
                uN = reader.GetString(0);
                pW = reader.GetString(1);
            }

            if (uN == user && pW == pass)
            {
                MessageBox.Show("Login Successful.", "Succes!");

                switch (uN)
                {
                    case "Admin":
                        permissions = 1;
                        break;
                    case "Sales":
                        permissions = 2;
                        break;
                    case "Development":
                        permissions = 4;
                        break;
                    case "Finance":
                        permissions = 3;
                        break;
                    default:
                        MessageBox.Show("Er is iets fout gegaan bij 'IsLoggedIn()'");
                        permissions = 0;
                        break;
                }

                Form frmMain = new frm_Main(permissions);
                frmMain.StartPosition = FormStartPosition.CenterScreen;
                Program.setForm(frmMain);
                this.Close();
            }
            else if (uN != user || pW != pass)
            {
                MessageBox.Show("Invalid Username and/or Password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  
            }
            dbh.CloseCon();
        }