Ejemplo n.º 1
0
        public void viewMemberInfo(object vipNo, EventArgs s)
        {
            int    dBVersion = Program.GetDBVersion();
            string text      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            if (dBVersion == 0)
            {
                if (new frmDialogMember(vipNo.ToString()).ShowDialog() == DialogResult.Yes)
                {
                    if (Program.SystemMode == 1)
                    {
                        switchForm(new frmMainShopSimple(vipNo.ToString()));
                    }
                    else
                    {
                        switchForm(new frmMainShopSimpleWithMoney(vipNo.ToString()));
                    }
                }
            }
            else
            {
                if (dBVersion < 1 || !Program.IsFertilizer)
                {
                    return;
                }
                DialogResult dialogResult      = new frmDialogMember(vipNo.ToString()).ShowDialog();
                string[]     strParameterArray = new string[1]
                {
                    vipNo.ToString()
                };
                DataTable dataTable = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT * FROM hypos_CUST_RTL WHERE VipNo = {0} ", strParameterArray, CommandOperationType.ExecuteReaderReturnDataTable);
                if (dataTable.Rows.Count <= 0)
                {
                    return;
                }
                if (dataTable.Rows[0]["IdNo"].ToString().Length == 10)
                {
                    if ("Y".Equals(dataTable.Rows[0]["Verification"].ToString()))
                    {
                        if (dialogResult == DialogResult.Yes)
                        {
                            if (Program.SystemMode == 1)
                            {
                                switchForm(new frmMainShopSimple(vipNo.ToString()));
                            }
                            else
                            {
                                switchForm(new frmMainShopSimpleWithMoney(vipNo.ToString()));
                            }
                            AutoClosingMessageBox.Show("會員符合購肥補助資格");
                        }
                        return;
                    }
                    string   text2 = new UploadVerification().farmerInfo(dataTable.Rows[0]["IdNo"].ToString());
                    string[] strParameterArray2 = new string[4]
                    {
                        dataTable.Rows[0]["Name"].ToString(),
                        dataTable.Rows[0]["IdNo"].ToString(),
                        text,
                        vipNo.ToString()
                    };
                    DataTable dataTable2 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT * FROM hypos_CUST_RTL ", null, CommandOperationType.ExecuteReaderReturnDataTable);
                    if (text2.Equals("符合補助資格"))
                    {
                        if (dataTable2.Rows.Count > 0)
                        {
                            DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_CUST_RTL SET Verification = 'Y', IdNo = {1}, LastVerificationTime = {2} WHERE VipNo = {3}", strParameterArray2, CommandOperationType.ExecuteNonQuery);
                        }
                        else
                        {
                            DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_CUST_RTL ( Name, IdNo, Verification, LastVerificationTime) VALUES( {0}, {1}, 'Y', {2}) ", strParameterArray2, CommandOperationType.ExecuteNonQuery);
                        }
                        AutoClosingMessageBox.Show("驗證成功。");
                    }
                    else if (text2.Equals("購肥帳號密碼驗證錯誤"))
                    {
                        AutoClosingMessageBox.Show("帳號密碼有誤,請重新確認您的帳號密碼。");
                        if (dataTable2.Rows.Count > 0)
                        {
                            DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_CUST_RTL SET Verification = 'N', IdNo = {1}, LastVerificationTime = {2} WHERE VipNo = {3} ", strParameterArray2, CommandOperationType.ExecuteNonQuery);
                        }
                        else
                        {
                            DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_CUST_RTL ( Name, IdNo, Verification, LastVerificationTime) VALUES( {0}, {1}, 'N', {2}) ", strParameterArray2, CommandOperationType.ExecuteNonQuery);
                        }
                    }
                    else if (text2.Equals("偵測不到網路連線,請確認網路正常後再使用檢查補助") && dataTable.Rows.Count > 0 && "Y".Equals(dataTable.Rows[0]["Verification"].ToString()))
                    {
                        AutoClosingMessageBox.Show("會員符合購肥補助資格");
                    }
                    if (dialogResult == DialogResult.Yes)
                    {
                        if (Program.SystemMode == 1)
                        {
                            switchForm(new frmMainShopSimple(vipNo.ToString()));
                        }
                        else
                        {
                            switchForm(new frmMainShopSimpleWithMoney(vipNo.ToString()));
                        }
                    }
                }
                else if ("".Equals(dataTable.Rows[0]["IdNo"].ToString()))
                {
                    if (dialogResult == DialogResult.Yes)
                    {
                        if (Program.SystemMode == 1)
                        {
                            switchForm(new frmMainShopSimple(vipNo.ToString()));
                        }
                        else
                        {
                            switchForm(new frmMainShopSimpleWithMoney(vipNo.ToString()));
                        }
                    }
                }
                else
                {
                    AutoClosingMessageBox.Show("身分證字號錯誤");
                }
            }
        }
Ejemplo n.º 2
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            if ("請輸入登入帳號".Equals(tb_account.Text) || "請輸入登入密碼".Equals(tb_password.Text))
            {
                AutoClosingMessageBox.Show("請輸入登入帳號與密碼");
                return;
            }
            DataTable dataTable = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "*", "hypos_User", "Account = {0}", "", null, new string[1]
            {
                tb_account.Text
            }, CommandOperationType.ExecuteReaderReturnDataTable);

            if (dataTable.Rows.Count > 0)
            {
                if (int.Parse(dataTable.Rows[0]["Status"].ToString()) != 0)
                {
                    AutoClosingMessageBox.Show("此帳號已被停用,請通知管理員");
                }
                else if (dataTable.Rows[0]["Password"].ToString().Equals(tb_password.Text))
                {
                    DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_User set LastLogin = datetime('now') WHERE Account = {0}", new string[1]
                    {
                        tb_account.Text
                    }, CommandOperationType.ExecuteNonQuery);
                    AutoClosingMessageBox.Show("登入成功");
                    Program.Casher   = tb_account.Text;
                    Program.RoleType = int.Parse(dataTable.Rows[0]["Type"].ToString());
                    if (Program.IsFertilizer)
                    {
                        AutoClosingMessageBox.Show("驗證帳號密碼中");
                        string text = new UploadVerification().retailData();
                        if (text.Equals("驗證成功"))
                        {
                            Program.IsSaleOfFertilizer = true;
                        }
                        else if (text.Equals("購肥帳號密碼驗證錯誤"))
                        {
                            Program.IsSaleOfFertilizer = false;
                            if (((DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT * FROM hypos_ShopInfoManage", null, CommandOperationType.ExecuteReaderReturnDataTable)).Rows.Count > 0)
                            {
                                try
                                {
                                    DataTable dataTable3 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_ShopInfoManage SET FertilizerPassword = ''  ", null, CommandOperationType.ExecuteScalar);
                                }
                                catch (Exception)
                                {
                                    AutoClosingMessageBox.Show("購肥帳號密碼驗證錯誤,商家無法販賣介接肥料");
                                }
                            }
                        }
                        else if (text.Equals("偵測不到網路連線,請確認網路正常後再選入商品"))
                        {
                            DataTable dataTable2 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT * FROM hypos_ShopInfoManage", null, CommandOperationType.ExecuteReaderReturnDataTable);
                            if (dataTable2.Rows.Count > 0 && !dataTable2.Rows[0]["FertilizerAccount"].ToString().Equals("") && !dataTable2.Rows[0]["FertilizerPassword"].ToString().Equals(""))
                            {
                                Program.IsSaleOfFertilizer = true;
                            }
                        }
                    }
                    switchForm(new frmNews());
                }
                else
                {
                    AutoClosingMessageBox.Show("密碼不正確,請重新輸入");
                }
            }
            else
            {
                AutoClosingMessageBox.Show("帳號不存在,請檢查您輸入的帳號");
            }
        }