Пример #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string name          = textBoxName.Text;
                string address_1     = textBoxAddress1.Text;
                string address_2     = textBoxAddress2.Text;
                string mobile_1      = textBoxMobile1.Text;
                string mobile_2      = textBoxMobile2.Text;
                string phone_1       = textBoxPhone1.Text;
                string phone_2       = textBoxPhone2.Text;
                string fax_1         = textBoxFax1.Text;
                string fax_2         = textBoxFax2.Text;
                string vat_no        = textBoxVatNo.Text;
                string trade_license = textBoxTrade.Text;
                string tin_no        = textBoxTinNo.Text;
                string email         = textBoxEmail.Text;
                string website       = textBoxWebsite.Text;


                if (name == "")
                {
                    textBoxName.BackColor = Color.Plum;
                    MessageBox.Show("Please input Name");
                }

                else if (address_1 == "")
                {
                    textBoxAddress1.BackColor = Color.Plum;
                    MessageBox.Show("Please input Address 1");
                }
                else if (mobile_1 == "")
                {
                    textBoxMobile1.BackColor = Color.Plum;
                    MessageBox.Show("Please input Mobile 1");
                }
                else if (phone_1 == "")
                {
                    textBoxPhone1.BackColor = Color.Plum;
                    MessageBox.Show("Please input Phone 1");
                }
                else if (fax_1 == "")
                {
                    textBoxFax1.BackColor = Color.Plum;
                    MessageBox.Show("Please input Fax 1");
                }
                else if (vat_no == "")
                {
                    textBoxVatNo.BackColor = Color.Plum;
                    MessageBox.Show("Please input VAT NO");
                }
                else if (trade_license == "")
                {
                    textBoxTrade.BackColor = Color.Plum;
                    MessageBox.Show("Please input Trade License");
                }
                else if (tin_no == "")
                {
                    textBoxTinNo.BackColor = Color.Plum;
                    MessageBox.Show("Please input TIN NO");
                }
                else if (email == "")
                {
                    textBoxEmail.BackColor = Color.Plum;
                    MessageBox.Show("Please input Email");
                }
                else
                {
                    if (checkBoxAlreadyInfo.Checked)
                    {
                        SqlConnection connection = new SqlConnection(conStr);
                        string        query      = "UPDATE [company_info] SET name = '" + name + "', address_1 = '" + address_1 + "',  address_2 = '" + address_2 + "',mobile_1 = '" + mobile_1 + "',mobile_2 = '" + mobile_2 + "', phone_1 = '" + phone_1 + "',phone_2 = '" + phone_2 + "',fax_1 = '" + fax_1 + "',fax_2 = '" + fax_2 + "',vat_no = '" + vat_no + "',trade_license = '" + trade_license + "',tin_no = '" + tin_no + "',email = '" + email + "',website = '" + website + "', status = 1 WHERE id=1";

                        SqlCommand command = new SqlCommand(query, connection);
                        connection.Open();
                        int rowEffict = command.ExecuteNonQuery();
                        connection.Close();
                        if (rowEffict > 0)
                        {
                            MainBody mbody = new MainBody();
                            mbody.Show();
                            Hide();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Select \"I agree to the POS Software and Service  Agreement\"");
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void Log_IN()
        {
            DateTime now       = DateTime.Now;
            string   date      = now.ToString("yyyyMMdd");
            int      today     = Convert.ToInt32(date);
            int      last_date = 20191230;

            if (last_date < today)
            {
                Trial tri = new Trial();
                tri.Show();
                Hide();
            }

            else
            {
                try
                {
                    string userName = textBoxUserName.Text;
                    userName = userName.Replace("'", "Sonali");
                    userName = userName.Replace("\"", "Sonali");
                    userName = userName.Replace("or", "Sonali");
                    userName = userName.Replace("OR", "Sonali");
                    userName = userName.Replace("-", "Sonali");
                    userName = userName.Replace("--", "Sonali");
                    userName = userName.Replace("=", "Sonali");
                    userName = userName.Replace("==", "Sonali");
                    userName = userName.Replace("===", "Sonali");
                    userName = userName.Replace(" ", "Sonali");
                    userName = userName.Replace("  ", "Sonali");
                    userName = userName.Replace("   ", "Sonali");
                    userName = userName.Replace("*", "Sonali");
                    string password = textBoxPassword.Text;
                    password = password.Replace(" ", "Sonali");
                    int Role  = 0;
                    int error = 0;
                    loguser = userName;
                    string        conStr     = ConfigurationManager.ConnectionStrings["PosConString"].ToString();
                    SqlConnection connection = new SqlConnection(conStr);
                    string        query      = "SELECT * FROM [User] WHERE UserName = @userName AND Password= @Password";
                    SqlCommand    command    = new SqlCommand(query, connection);

                    SqlParameter param  = new SqlParameter();
                    SqlParameter param2 = new SqlParameter();

                    param.ParameterName = "@userName";
                    param.Value         = userName;

                    param2.ParameterName = "@Password";
                    param2.Value         = password;

                    command.Parameters.Add(param);
                    command.Parameters.Add(param2);

                    connection.Open();

                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        Role      = Convert.ToInt32(reader["Role"]);
                        loguserID = Convert.ToInt32(reader["ID"]);
                        error     = 1;
                    }
                    loguserRole = Role;
                    connection.Close();



                    if (error == 0)
                    {
                        MessageBox.Show("User Name or Password incorrect...");
                    }
                    if (error != 0)
                    {
                        // User Log Info Start

                        string CurrentUser    = userName;
                        int    Companyid      = CompanyID;
                        string ComputerName   = GetUserLogInfo.hostName;
                        string MacAddress     = GetUserLogInfo.GetMacAddress();
                        string LocalIPAddress = GetUserLogInfo.GetLocalIPAddress();
                        // string RealIPAddress = GetUserLogInfo.GetRealIPAddress();
                        string status = "1";


                        //  InsertUserLog(CurrentUser, Companyid, ComputerName, MacAddress, LocalIPAddress, RealIPAddress, status);
                        InsertUserLog(CurrentUser, Companyid, ComputerName, MacAddress, LocalIPAddress, status);        // Without Real IP

                        // User Log Info End

                        MainBody amainbody = new MainBody();
                        amainbody.Show();
                        Hide();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Database Connection Failed...");
                }
            }
        }