コード例 #1
0
ファイル: RegisterNewCustomer.cs プロジェクト: prix79/B4U_POS
        /// <summary>
        /// Handles the Click event of the btnRegister control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void btnRegister_Click(object sender, EventArgs e)
        {
            if (txtFirstName.Text.Trim() == "")
            {
                MyMessageBox.ShowBox("INPUT FIRST NAME", "ERROR");
                txtFirstName.Select();
                txtFirstName.Focus();
                return;
            }

            if (txtLastName.Text.Trim() == "")
            {
                MyMessageBox.ShowBox("INPUT LAST NAME", "ERROR");
                txtLastName.Select();
                txtLastName.Focus();
                return;
            }

            /*if (DateTime.TryParse(txtDateOfBirth.Text, out d1))
             * {
             *  dob = string.Format("{0:MM/dd/yyyy}", d1);
             * }
             * else
             * {
             *  MyMessageBox.ShowBox("INVALID DATE", "ERROR");
             *  txtDateOfBirth.SelectAll();
             *  txtDateOfBirth.Focus();
             *  return;
             * }*/

            if (ValidateDate(txtDateOfBirth.Text) == true)
            {
                dob = txtDateOfBirth.Text;
            }
            else
            {
                MyMessageBox.ShowBox("INVALID DATE", "ERROR");
                txtDateOfBirth.SelectAll();
                txtDateOfBirth.Focus();
                return;
            }

            if (txtAddress.Text.Trim() == "")
            {
                MyMessageBox.ShowBox("INPUT ADDRESS", "ERROR");
                txtAddress.SelectAll();
                txtAddress.Focus();
                return;
            }

            if (txtCity.Text.Trim() == "")
            {
                MyMessageBox.ShowBox("INPUT CITY", "ERROR");
                txtCity.SelectAll();
                txtCity.Focus();
                return;
            }

            if (txtState.Text.Trim() == "")
            {
                MyMessageBox.ShowBox("INPUT STATE", "ERROR");
                txtState.Select();
                txtState.Focus();
                return;
            }
            else if (txtState.Text.Trim().Length != 2)
            {
                MyMessageBox.ShowBox("INPUT USPS FORMAT (TWO LETTERS ONLY)", "ERROR");
                txtState.SelectAll();
                txtState.Focus();
                return;
            }

            if (txtZipCode.Text.Trim() == "")
            {
                MyMessageBox.ShowBox("INPUT ZIP CODE", "ERROR");
                txtZipCode.Select();
                txtZipCode.Focus();
                return;
            }
            else if (txtZipCode.Text.Trim().Length != 5)
            {
                MyMessageBox.ShowBox("FIVE DIGIT ONLY", "ERROR");
                txtZipCode.SelectAll();
                txtZipCode.Focus();
                return;
            }
            else
            {
                if (Int64.TryParse(txtZipCode.Text, out zipCode))
                {
                }
                else
                {
                    MyMessageBox.ShowBox("INVALID ZIPCODE", "ERROR");
                    txtZipCode.SelectAll();
                    txtZipCode.Focus();
                    return;
                }
            }

            if (txtHomePhone.Text.Trim() != "")
            {
                if (txtHomePhone.Text.Trim().Length != 10)
                {
                    MyMessageBox.ShowBox("INVALID HOME PHONE NUMBER (INPUT 10 DIGIT ONLY)", "ERROR");
                    txtHomePhone.SelectAll();
                    txtHomePhone.Focus();
                    return;
                }
                else
                {
                    if (Int64.TryParse(txtHomePhone.Text, out homePhone))
                    {
                    }
                    else
                    {
                        MyMessageBox.ShowBox("INVALID HOME PHONE NUMBER (INPUT 10 DIGIT ONLY)", "ERROR");
                        txtHomePhone.SelectAll();
                        txtHomePhone.Focus();
                        return;
                    }
                }
            }

            if (txtCellPhone.Text.Trim() != "")
            {
                if (txtCellPhone.Text.Trim().Length != 10)
                {
                    MyMessageBox.ShowBox("INVALID CELL PHONE NUMBER (INPUT 10 DIGIT ONLY)", "ERROR");
                    txtCellPhone.SelectAll();
                    txtCellPhone.Focus();
                    return;
                }
                else
                {
                    if (Int64.TryParse(txtCellPhone.Text, out cellPhone))
                    {
                    }
                    else
                    {
                        MyMessageBox.ShowBox("INVALID CELL PHONE NUMBER (INPUT 10 DIGIT ONLY)", "ERROR");
                        txtCellPhone.SelectAll();
                        txtCellPhone.Focus();
                        return;
                    }
                }
            }

            if (txtMemberCode.Text.Trim() == "")
            {
                MyMessageBox.ShowBox("INPUT MEMBER CODE", "ERROR");
                txtMemberCode.SelectAll();
                txtMemberCode.Focus();
                return;
            }

            if (cmbMemberType.SelectedIndex == 1)
            {
                if (txtLicenseNumber.Text == "")
                {
                    MyMessageBox.ShowBox("INPUT LICENSE NUMBER", "ERROR");
                    txtLicenseNumber.Select();
                    txtLicenseNumber.Focus();
                    return;
                }
            }

            if (double.TryParse(txtMemberPoints.Text, out memberPoints))
            {
            }
            else
            {
                MyMessageBox.ShowBox("INPUT VALID MEMBER POINTS", "ERROR");
                txtMemberPoints.SelectAll();
                txtMemberPoints.Focus();
                return;
            }

            if (ValidateDate(txtStartDate.Text) == true)
            {
                startDate = txtStartDate.Text;
            }
            else
            {
                MyMessageBox.ShowBox("INVALID START DATE", "ERROR");
                txtStartDate.SelectAll();
                txtStartDate.Focus();
                return;
            }

            if (ValidateDate(txtExpirationDate.Text) == true)
            {
                expDate = txtExpirationDate.Text;
            }
            else
            {
                MyMessageBox.ShowBox("INVALID EXPIRATION DATE", "ERROR");
                txtExpirationDate.SelectAll();
                txtExpirationDate.Focus();
                return;
            }

            if (cmbMemberType.SelectedIndex == 1)
            {
                if (BeauticianAuth == true)
                {
                    try
                    {
                        btnRegister.Enabled = false;

                        cmd.CommandText = "Create_New_Member";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Connection  = parentForm.connHQ;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@StoreCode", SqlDbType.NVarChar).Value     = parentForm.storeCode;
                        cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value     = txtFirstName.Text.Trim().ToUpper();
                        cmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value      = txtLastName.Text.Trim().ToUpper();
                        cmd.Parameters.Add("@DateOfBirth", SqlDbType.DateTime).Value   = Convert.ToDateTime(dob);
                        cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value       = txtAddress.Text.Trim().ToUpper();
                        cmd.Parameters.Add("@City", SqlDbType.NVarChar).Value          = txtCity.Text.Trim().ToUpper();
                        cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value         = txtState.Text.Trim().ToUpper();
                        cmd.Parameters.Add("@ZipCode", SqlDbType.NVarChar).Value       = Convert.ToString(zipCode);
                        cmd.Parameters.Add("@HomePhone", SqlDbType.NVarChar).Value     = txtHomePhone.Text.Trim();
                        cmd.Parameters.Add("@CellPhone", SqlDbType.NVarChar).Value     = txtCellPhone.Text.Trim();
                        cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value         = txtEmail.Text.Trim();
                        cmd.Parameters.Add("@MemberCode", SqlDbType.BigInt).Value      = memberCode;
                        cmd.Parameters.Add("@MemberType", SqlDbType.NVarChar).Value    = cmbMemberType.Text.Trim().ToUpper();
                        cmd.Parameters.Add("@LicenseNumber", SqlDbType.NVarChar).Value = txtLicenseNumber.Text.Trim();
                        //cmd.Parameters.Add("@DiscountOption", SqlDbType.Money).Value = Convert.ToDouble(lblDiscountOption.Text.Substring(0, lblDiscountOption.Text.Length - 1));
                        cmd.Parameters.Add("@DiscountOption", SqlDbType.Money).Value     = discRate;
                        cmd.Parameters.Add("@MemberPoints", SqlDbType.Money).Value       = memberPoints;
                        cmd.Parameters.Add("@StartDate", SqlDbType.DateTime).Value       = Convert.ToDateTime(startDate);
                        cmd.Parameters.Add("@ExpirationDate", SqlDbType.DateTime).Value  = Convert.ToDateTime(expDate);
                        cmd.Parameters.Add("@SchoolGraduated", SqlDbType.NVarChar).Value = txtSchoolGraduated.Text.Trim().ToUpper();
                        cmd.Parameters.Add("@Memo", SqlDbType.NVarChar).Value            = txtMemo.Text.Trim().ToUpper();
                        if (rdoBtnSETrue.Checked == true)
                        {
                            cmd.Parameters.Add("@StoreEmployee", SqlDbType.Bit).Value = true;
                        }
                        else
                        {
                            cmd.Parameters.Add("@StoreEmployee", SqlDbType.Bit).Value = false;
                        }
                        cmd.Parameters.Add("@UpdateStoreCode", SqlDbType.NVarChar).Value = parentForm.storeCode.ToUpper().ToString();
                        cmd.Parameters.Add("@UpdateID", SqlDbType.NVarChar).Value        = parentForm.employeeID.ToUpper().ToString();
                        cmd.Parameters.Add("@UpdateDate", SqlDbType.DateTime).Value      = DateTime.Now;


                        parentForm.connHQ.Open();
                        cmd.ExecuteNonQuery();
                        parentForm.connHQ.Close();

                        MyMessageBox.ShowBox("SUCCESSFULLY REGISTERED", "INFORMATION");

                        Resetting();
                    }
                    catch
                    {
                        MyMessageBox.ShowBox("UPDATE FAILED ERROR", "ERROR");
                        parentForm.connHQ.Close();
                        return;
                    }
                }
                else
                {
                    MyMessageBox.ShowBox("PLEASE PASS THE AUTHENTICATION BY MANAGER TO REGISTER A BEAUTICAIN MEMBER.", "WARNING");

                    Authentication authenticationForm = new Authentication(24);
                    authenticationForm.parentForm1  = this.parentForm;
                    authenticationForm.parentForm12 = this;
                    authenticationForm.ShowDialog();
                }
            }
            else
            {
                try
                {
                    btnRegister.Enabled = false;

                    cmd.CommandText = "Create_New_Member";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection  = parentForm.connHQ;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("@StoreCode", SqlDbType.NVarChar).Value     = parentForm.storeCode;
                    cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value     = txtFirstName.Text.Trim().ToUpper();
                    cmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value      = txtLastName.Text.Trim().ToUpper();
                    cmd.Parameters.Add("@DateOfBirth", SqlDbType.DateTime).Value   = Convert.ToDateTime(dob);
                    cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value       = txtAddress.Text.Trim().ToUpper();
                    cmd.Parameters.Add("@City", SqlDbType.NVarChar).Value          = txtCity.Text.Trim().ToUpper();
                    cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value         = txtState.Text.Trim().ToUpper();
                    cmd.Parameters.Add("@ZipCode", SqlDbType.NVarChar).Value       = Convert.ToString(zipCode);
                    cmd.Parameters.Add("@HomePhone", SqlDbType.NVarChar).Value     = txtHomePhone.Text.Trim();
                    cmd.Parameters.Add("@CellPhone", SqlDbType.NVarChar).Value     = txtCellPhone.Text.Trim();
                    cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value         = txtEmail.Text.Trim();
                    cmd.Parameters.Add("@MemberCode", SqlDbType.BigInt).Value      = memberCode;
                    cmd.Parameters.Add("@MemberType", SqlDbType.NVarChar).Value    = cmbMemberType.Text.Trim().ToUpper();
                    cmd.Parameters.Add("@LicenseNumber", SqlDbType.NVarChar).Value = txtLicenseNumber.Text.Trim();
                    //cmd.Parameters.Add("@DiscountOption", SqlDbType.Money).Value = Convert.ToDouble(lblDiscountOption.Text.Substring(0, lblDiscountOption.Text.Length - 1));
                    cmd.Parameters.Add("@DiscountOption", SqlDbType.Money).Value     = discRate;
                    cmd.Parameters.Add("@MemberPoints", SqlDbType.Money).Value       = memberPoints;
                    cmd.Parameters.Add("@StartDate", SqlDbType.DateTime).Value       = Convert.ToDateTime(startDate);
                    cmd.Parameters.Add("@ExpirationDate", SqlDbType.DateTime).Value  = Convert.ToDateTime(expDate);
                    cmd.Parameters.Add("@SchoolGraduated", SqlDbType.NVarChar).Value = txtSchoolGraduated.Text.Trim().ToUpper();
                    cmd.Parameters.Add("@Memo", SqlDbType.NVarChar).Value            = txtMemo.Text.Trim().ToUpper();
                    if (rdoBtnSETrue.Checked == true)
                    {
                        cmd.Parameters.Add("@StoreEmployee", SqlDbType.Bit).Value = true;
                    }
                    else
                    {
                        cmd.Parameters.Add("@StoreEmployee", SqlDbType.Bit).Value = false;
                    }
                    cmd.Parameters.Add("@UpdateStoreCode", SqlDbType.NVarChar).Value = parentForm.storeCode.ToUpper().ToString();
                    cmd.Parameters.Add("@UpdateID", SqlDbType.NVarChar).Value        = parentForm.employeeID.ToUpper().ToString();
                    cmd.Parameters.Add("@UpdateDate", SqlDbType.DateTime).Value      = DateTime.Now;


                    parentForm.connHQ.Open();
                    cmd.ExecuteNonQuery();
                    parentForm.connHQ.Close();

                    MyMessageBox.ShowBox("SUCCESSFULLY REGISTERED", "INFORMATION");

                    Resetting();
                }
                catch
                {
                    MyMessageBox.ShowBox("UPDATE FAILED ERROR", "ERROR");
                    parentForm.connHQ.Close();
                    return;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles the Click event of the btnCheckOut control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnCheckOut_Click(object sender, EventArgs e)
        {
            if (cmbTerminalType.Text == "")
            {
                MyMessageBox.ShowBox("PLEASE SELECT CARD TYPE", "ERROR");
                return;
            }

            terminalType = cmbTerminalType.Text.Trim().ToUpper();

            if (cmbTerminalType.SelectedIndex == 2)
            {
                if (txtCardNum.Text.Length == 17)
                {
                    RefCardNum = txtCardNum.Text.Substring(txtCardNum.Text.Length - 4, 4);

                    if (int.TryParse(RefCardNum, out nRefCardNum))
                    {
                    }
                    else
                    {
                        MyMessageBox.ShowBox("INVALID LAST 4 DIGIT", "ERROR");
                        txtCardNum.Select(13, txtCardNum.Text.Length - 12);
                        txtCardNum.Focus();
                        return;
                    }
                }
                else
                {
                    MyMessageBox.ShowBox("INPUT LAST 4 DIGIT", "ERROR");
                    txtCardNum.Select(13, txtCardNum.Text.Length - 12);
                    txtCardNum.Focus();
                    return;
                }
            }
            else
            {
                if (txtCardNum.Text.Length == 19)
                {
                    RefCardNum = txtCardNum.Text.Substring(txtCardNum.Text.Length - 4, 4);

                    if (int.TryParse(RefCardNum, out nRefCardNum))
                    {
                    }
                    else
                    {
                        MyMessageBox.ShowBox("INVALID LAST 4 DIGIT", "ERROR");
                        txtCardNum.Select(15, txtCardNum.Text.Length - 15);
                        txtCardNum.Focus();
                        return;
                    }
                }
                else
                {
                    MyMessageBox.ShowBox("INPUT LAST 4 DIGIT", "ERROR");
                    txtCardNum.Select(15, txtCardNum.Text.Length - 15);
                    txtCardNum.Focus();
                    return;
                }
            }

            SellDate = string.Format("{0:MM/dd/yyyy}", DateTime.Now);
            SellTime = string.Format("{0:T}", DateTime.Now);

            SqlCommand cmd_RefCreditTransaction = new SqlCommand("Create_RefCreditTransaction", parentForm.parentForm.conn);

            cmd_RefCreditTransaction.CommandType = CommandType.StoredProcedure;
            cmd_RefCreditTransaction.Parameters.Add("@ReceiptID", SqlDbType.BigInt).Value    = 99;
            cmd_RefCreditTransaction.Parameters.Add("@TroutD", SqlDbType.NVarChar).Value     = "TERMINAL";
            cmd_RefCreditTransaction.Parameters.Add("@AuthNum", SqlDbType.NVarChar).Value    = "CREDIT";
            cmd_RefCreditTransaction.Parameters.Add("@RefCardNum", SqlDbType.NVarChar).Value = RefCardNum;
            cmd_RefCreditTransaction.Parameters.Add("@CardType", SqlDbType.NVarChar).Value   = TerminalCreditType(cmbTerminalType.SelectedIndex);
            cmd_RefCreditTransaction.Parameters.Add("@Amount", SqlDbType.Money).Value        = terminalPayAmount;
            cmd_RefCreditTransaction.Parameters.Add("@IssueDate", SqlDbType.NVarChar).Value  = SellDate;
            cmd_RefCreditTransaction.Parameters.Add("@IssueTime", SqlDbType.NVarChar).Value  = SellTime;

            parentForm.parentForm.conn.Open();
            cmd_RefCreditTransaction.ExecuteNonQuery();
            parentForm.parentForm.conn.Close();

            parentForm.dt.Rows.Add("TERMINAL", 3, terminalPayAmount, parentForm.parentForm.storeCode);
            parentForm.Binding_dataGridView1();

            parentForm.Check_RemainingAmount();
            this.Close();
        }
コード例 #3
0
        /// <summary>
        /// Handles the Click event of the btnLineNoTax control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void btnLineNoTax_Click(object sender, EventArgs e)
        {
            if (parentForm.dataGridView1.RowCount == 0)
            {
                MyMessageBox.ShowBox("NO ITEM", "ERROR");
                //MessageBox.Show("No Item", "Error");
                return;
            }

            if (auth == true)
            {
                /*if (Convert.ToDouble(parentForm.dataGridView1.SelectedCells[6].Value) != 0)
                 * {
                 *  if (Convert.ToDouble(parentForm.dataGridView1.SelectedCells[4].Value) == 0)
                 *  {
                 *      qty = Convert.ToInt16(parentForm.dataGridView1.SelectedCells[2].Value);
                 *      unitPrice = Convert.ToDouble(parentForm.dataGridView1.SelectedCells[3].Value);
                 *      price = qty * unitPrice;
                 *      parentForm.dataGridView1.SelectedCells[5].Value = Math.Round(price, 2);
                 *      parentForm.dataGridView1.SelectedCells[6].Value = price * 0;
                 *
                 *      double subTotal = 0;
                 *      double tax = 0;
                 *      for (int i = 0; i < parentForm.dataGridView1.RowCount; i++)
                 *      {
                 *          subTotal = subTotal + Convert.ToDouble(parentForm.dataGridView1.Rows[i].Cells[5].Value);
                 *          tax = tax + Convert.ToDouble(parentForm.dataGridView1.Rows[i].Cells[6].Value);
                 *      }
                 *      //double tax = subTotal * parentForm.storeTaxRate;
                 *      double grandTotal = subTotal + tax;
                 *      parentForm.lblSubTotal.Text = string.Format("{0:$0.00}", (Math.Round(subTotal, 2)));
                 *      parentForm.lblTax.Text = string.Format("{0:$0.00}", (Math.Round(tax, 2)));
                 *      parentForm.lblGrandTotal.Text = string.Format("{0:$0.00}", grandTotal);
                 *
                 *      discountPrice = 0;
                 *      price = 0;
                 *
                 *      parentForm.Enabled = true;
                 *      this.Close();
                 *      parentForm.richTxtUpc.Focus();
                 *      parentForm.richTxtUpc.Select();
                 *  }
                 *  else
                 *  {
                 *      qty = Convert.ToInt16(parentForm.dataGridView1.SelectedCells[2].Value);
                 *      discountPrice = Convert.ToDouble(parentForm.dataGridView1.SelectedCells[4].Value);
                 *      price = qty * discountPrice;
                 *      parentForm.dataGridView1.SelectedCells[4].Value = discountPrice;
                 *      parentForm.dataGridView1.SelectedCells[5].Value = Math.Round(price, 2);
                 *      parentForm.dataGridView1.SelectedCells[6].Value = price * 0;
                 *
                 *      double subTotal = 0;
                 *      double tax = 0;
                 *      for (int i = 0; i < parentForm.dataGridView1.RowCount; i++)
                 *      {
                 *          subTotal = subTotal + Convert.ToDouble(parentForm.dataGridView1.Rows[i].Cells[5].Value);
                 *          tax = tax + Convert.ToDouble(parentForm.dataGridView1.Rows[i].Cells[6].Value);
                 *      }
                 *      //double tax = subTotal * parentForm.storeTaxRate;
                 *      double grandTotal = subTotal + tax;
                 *      parentForm.lblSubTotal.Text = string.Format("{0:$0.00}", (Math.Round(subTotal, 2)));
                 *      parentForm.lblTax.Text = string.Format("{0:$0.00}", (Math.Round(tax, 2)));
                 *      parentForm.lblGrandTotal.Text = string.Format("{0:$0.00}", grandTotal);
                 *
                 *      discountPrice = 0;
                 *      price = 0;
                 *
                 *      parentForm.Enabled = true;
                 *      this.Close();
                 *      parentForm.richTxtUpc.Focus();
                 *      parentForm.richTxtUpc.Select();
                 *  }
                 * }
                 * else
                 * {
                 *  MyMessageBox.ShowBox("ALREADY NO TAX ITEM", "ERROR");
                 *  //MessageBox.Show("It is already no tax item", "Error");
                 *  return;
                 * }*/


                parentForm.dataGridView1.SelectedCells[11].Value = false;

                parentForm.Calculation();

                parentForm.Enabled = true;
                this.Close();
                parentForm.richTxtUpc.Focus();
                parentForm.richTxtUpc.Select();
            }
            else
            {
                Authentication authenticationForm = new Authentication(13);
                authenticationForm.parentForm1 = this.parentForm;
                authenticationForm.parentForm2 = this;
                authenticationForm.ShowDialog();
            }
        }
コード例 #4
0
        /// <summary>
        /// Handles the Click event of the btnOK control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            employeeID       = txtEmployeeID.Text.Trim().ToString().ToUpper();
            employeePassword = txtPsw.Text.Trim().ToString().ToUpper();

            if (parentForm2.managerID.ToUpper() == employeeID.ToUpper())
            {
                MyMessageBox.ShowBox("WITNESS ID CAN NOT BE SAME WITH MANAGER ID", "ERROR");
                return;
            }

            SqlCommand cmd = new SqlCommand("Get_User", parentForm1.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@empLoginID", SqlDbType.NVarChar).Value  = employeeID.ToUpper().ToString();
            cmd.Parameters.Add("@empPassword", SqlDbType.NVarChar).Value = employeePassword;
            SqlParameter UserFirstName_Param = cmd.Parameters.Add("@empFirstName", SqlDbType.NVarChar, 50);
            SqlParameter UserLastName_Param  = cmd.Parameters.Add("@empLastName", SqlDbType.NVarChar, 50);

            UserFirstName_Param.Direction = ParameterDirection.Output;
            UserLastName_Param.Direction  = ParameterDirection.Output;

            parentForm1.conn.Open();
            cmd.ExecuteNonQuery();
            parentForm1.conn.Close();

            if (cmd.Parameters["@empFirstName"].Value == DBNull.Value)
            {
                MyMessageBox.ShowBox("AUTHENTICATION FAILED", "ERROR");
                txtPsw.SelectAll();
                txtPsw.Focus();
                return;
            }
            else
            {
                if (option == 0)
                {
                    parentForm2.boolSecondAuthentication = true;
                    parentForm2.witnessID = employeeID.Trim().ToUpper().ToString();
                    this.Close();
                    parentForm2.btnRefund_Click(null, null);
                    parentForm2.boolSecondAuthentication = false;
                }
                else if (option == 1)
                {
                    parentForm2.boolSecondAuthentication = true;
                    parentForm2.witnessID = employeeID.Trim().ToUpper().ToString();
                    this.Close();
                    parentForm2.btnVoid_Click(null, null);
                    parentForm2.boolSecondAuthentication = false;
                }
                else if (option == 2)
                {
                    parentForm2.boolSecondAuthentication = true;
                    parentForm2.witnessID = employeeID.Trim().ToUpper().ToString();
                    this.Close();
                    parentForm2.btnStoreCredit_Click(null, null);
                    parentForm2.boolSecondAuthentication = false;
                }
            }
        }
コード例 #5
0
ファイル: CustomerMain.cs プロジェクト: prix79/B4U_POS
        /// <summary>
        /// Handles the Click event of the btnSearch control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void btnSearch_Click(object sender, EventArgs e)
        {
            if (rdoBtnFirstName.Checked == true)
            {
                cmd.CommandText = "Show_Customer_With_Keyword";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = parentForm.conn;
                cmd.Parameters.Clear();
                cmd.Parameters.Add("@Index", SqlDbType.Int).Value        = 1;
                cmd.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = txtSearchKeyword.Text.ToUpper() + "%";
                SqlDataAdapter adapt = new SqlDataAdapter();
                adapt.SelectCommand = cmd;

                parentForm.conn.Open();
                dt.Clear();
                adapt.Fill(dt);
                parentForm.conn.Close();

                BindingData();
            }
            else if (rdoBtnLastName.Checked == true)
            {
                cmd.CommandText = "Show_Customer_With_Keyword";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = parentForm.conn;
                cmd.Parameters.Clear();
                cmd.Parameters.Add("@Index", SqlDbType.Int).Value        = 2;
                cmd.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = txtSearchKeyword.Text.ToUpper() + "%";
                SqlDataAdapter adapt = new SqlDataAdapter();
                adapt.SelectCommand = cmd;

                parentForm.conn.Open();
                dt.Clear();
                adapt.Fill(dt);
                parentForm.conn.Close();

                BindingData();
            }
            else if (rdoBtnHomePhone.Checked == true)
            {
                cmd.CommandText = "Show_Customer_With_Keyword";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = parentForm.conn;
                cmd.Parameters.Clear();
                cmd.Parameters.Add("@Index", SqlDbType.Int).Value        = 3;
                cmd.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = txtSearchKeyword.Text.ToUpper() + "%";
                SqlDataAdapter adapt = new SqlDataAdapter();
                adapt.SelectCommand = cmd;

                parentForm.conn.Open();
                dt.Clear();
                adapt.Fill(dt);
                parentForm.conn.Close();

                BindingData();
            }
            else if (rdoBtnCellPhone.Checked == true)
            {
                cmd.CommandText = "Show_Customer_With_Keyword";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = parentForm.conn;
                cmd.Parameters.Clear();
                cmd.Parameters.Add("@Index", SqlDbType.Int).Value        = 4;
                cmd.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = txtSearchKeyword.Text.ToUpper() + "%";
                SqlDataAdapter adapt = new SqlDataAdapter();
                adapt.SelectCommand = cmd;

                parentForm.conn.Open();
                dt.Clear();
                adapt.Fill(dt);
                parentForm.conn.Close();

                BindingData();
            }
            else if (rdoBtnMemberCode.Checked == true)
            {
                if (Int64.TryParse(txtSearchKeyword.Text, out memberCode))
                {
                    cmd.CommandText = "Show_Customer_With_Keyword";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection  = parentForm.conn;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("@Index", SqlDbType.Int).Value        = 5;
                    cmd.Parameters.Add("@Keyword", SqlDbType.NVarChar).Value = Convert.ToString(memberCode);
                    SqlDataAdapter adapt = new SqlDataAdapter();
                    adapt.SelectCommand = cmd;

                    parentForm.conn.Open();
                    dt.Clear();
                    adapt.Fill(dt);
                    parentForm.conn.Close();

                    BindingData();
                }
                else
                {
                    MyMessageBox.ShowBox("INPUT VALID MEMBER CODE", "ERROR");
                    txtSearchKeyword.SelectAll();
                    txtSearchKeyword.Focus();
                    return;
                }
            }

            lblNumberOfMembers.Text = Convert.ToString(dataGridView1.RowCount);
        }
コード例 #6
0
        /// <summary>
        /// Handles the Click event of the cmdOK control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (option == 0)
            {
                cashierID       = txtCashierID.Text.Trim().ToString().ToUpper();
                cashierPassword = txtPsw.Text.Trim().ToString().ToUpper();
                SqlCommand cmd = new SqlCommand("Get_User_LogIn_Info", parentForm1.conn);

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@empLoginID", SqlDbType.NVarChar).Value  = cashierID.ToUpper().ToString();
                cmd.Parameters.Add("@empPassword", SqlDbType.NVarChar).Value = cashierPassword;
                SqlParameter UserName_Param  = cmd.Parameters.Add("@empFirstName", SqlDbType.NVarChar, 50);
                SqlParameter UserLevel_Param = cmd.Parameters.Add("@empAccessLv", SqlDbType.TinyInt);
                UserName_Param.Direction  = ParameterDirection.Output;
                UserLevel_Param.Direction = ParameterDirection.Output;

                parentForm1.conn.Open();
                cmd.ExecuteNonQuery();
                parentForm1.conn.Close();

                if (cmd.Parameters["@empFirstName"].Value == DBNull.Value)
                {
                    MyMessageBox.ShowBox("INVALID ACCOUNT", "ERROR");
                    txtPsw.SelectAll();
                    txtPsw.Focus();
                    //MessageBox.Show("Invalid account", "Error");
                }
                else
                {
                    parentForm1.smDiscount  = true;
                    parentForm1.smCashierID = cashierID;
                    this.Close();
                    parentForm2.btnSocialMediaDiscount_Click(null, null);
                }
            }
            else if (option == 1)
            {
                cashierID       = txtCashierID.Text.Trim().ToString().ToUpper();
                cashierPassword = txtPsw.Text.Trim().ToString().ToUpper();
                SqlCommand cmd = new SqlCommand("Get_User_LogIn_Info", parentForm1.conn);

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@empLoginID", SqlDbType.NVarChar).Value  = cashierID.ToUpper().ToString();
                cmd.Parameters.Add("@empPassword", SqlDbType.NVarChar).Value = cashierPassword;
                SqlParameter UserName_Param  = cmd.Parameters.Add("@empFirstName", SqlDbType.NVarChar, 50);
                SqlParameter UserLevel_Param = cmd.Parameters.Add("@empAccessLv", SqlDbType.TinyInt);
                UserName_Param.Direction  = ParameterDirection.Output;
                UserLevel_Param.Direction = ParameterDirection.Output;

                parentForm1.conn.Open();
                cmd.ExecuteNonQuery();
                parentForm1.conn.Close();

                if (cmd.Parameters["@empFirstName"].Value == DBNull.Value)
                {
                    MyMessageBox.ShowBox("INVALID ACCOUNT", "ERROR");
                    txtPsw.SelectAll();
                    txtPsw.Focus();
                    //MessageBox.Show("Invalid account", "Error");
                }
                else
                {
                    parentForm1.eDiscount1 = true;
                    parentForm1.eCashierID = cashierID;
                    this.Close();
                    parentForm2.btn25OFF_Click(null, null);
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Handles the Load event of the StartRegister control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void StartRegister_Load(object sender, EventArgs e)
        {
            SqlDataReader dReader;
            SqlCommand    cmd = new SqlCommand("Get_User_Level", parentForm.conn);

            cmd.CommandType = CommandType.StoredProcedure;

            parentForm.conn.Open();
            dReader = cmd.ExecuteReader();
            if (dReader.HasRows == true)
            {
                while (dReader.Read())
                {
                    namesCollection.Add(dReader["empLoginID"].ToString());
                }
            }
            else
            {
                MyMessageBox.ShowBox("USER DATA NOT FOUND", "ERROR");
                //MessageBox.Show("Data not found");
            }

            dReader.Close();
            parentForm.conn.Close();

            txtManagerID.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            txtManagerID.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            txtManagerID.AutoCompleteCustomSource = namesCollection;

            txt100Dollar.SelectAll();
            lblCashDrawer.Text = "$0.00";

            Int32  retVal;
            String errMsg;

            apiAlias.StatusMonitoring pMonitorCB = new apiAlias.StatusMonitoring(StatusMonitoring);

            try
            {
                // Open Printer Monitor of Status API.
                mpHandle = apiAlias.BiOpenMonPrinter(apiAlias.TYPE_PRINTER, parentForm.PRINTER_NAME);
                if (mpHandle < 0)
                {
                    MessageBox.Show("Failed to open printer status monitor.", "Printing error", MessageBoxButtons.OK);
                }
                else
                {
                    isFinish  = false;
                    cancelErr = false;

                    // Set the callback function that will monitor printer status.
                    retVal = apiAlias.BiSetStatusBackFunction(mpHandle, pMonitorCB);

                    if (retVal != apiAlias.SUCCESS)
                    {
                        MessageBox.Show("Failed to set callback function.", "Printing error", MessageBoxButtons.OK);
                    }
                    else
                    {
                        // Display the status/error message.
                        DisplayStatusMessage();

                        // If an error occurred, restore the recoverable error.
                        if (cancelErr)
                        {
                            retVal = apiAlias.BiCancelError(mpHandle);
                        }
                        else
                        {
                            // Call the function to open cash drawer.
                            OpenDrawer(parentForm.PRINTER_NAME);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                MessageBox.Show("Failed to open StatusAPI.", "Printing error", MessageBoxButtons.OK);
            }
            finally
            {
                // Close Printer Monitor.
                if (mpHandle > 0)
                {
                    if (apiAlias.BiCloseMonPrinter(mpHandle) != apiAlias.SUCCESS)
                    {
                        MessageBox.Show("Failed to close printer status monitor.", "Printing error", MessageBoxButtons.OK);
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Handles the Click event of the btnInput control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        public void btnInput_Click(object sender, EventArgs e)
        {
            if (richtxtStoreCreditID.Text == "")
            {
                MyMessageBox.ShowBox("INPUT STORECREDIT ID", "ERROR");
                richtxtStoreCreditID.Select();
                richtxtStoreCreditID.Focus();
            }
            else
            {
                lblCurrentBalance.Text   = "";
                lblRemainingBalance.Text = "";

                if (parentForm.StoreCode != cmbStoreCode.Text)
                {
                    if (auth == false)
                    {
                        Authentication authenticationForm = new Authentication(7);
                        authenticationForm.parentForm1 = this.parentForm.parentForm;
                        authenticationForm.parentForm5 = this;
                        authenticationForm.ShowDialog();
                    }
                    else
                    {
                        try
                        {
                            parentForm.newConn_StoreCredit = new SqlConnection(parentForm.parentForm.parentForm.OtherStoreConnectionString(cmbStoreCode.Text));

                            if (Int64.TryParse(richtxtStoreCreditID.Text, out storeCreditID))
                            {
                                //Store Credit Double Check
                                for (int i = 0; i < parentForm.dataGridView1.RowCount; i++)
                                {
                                    if (Convert.ToInt16(parentForm.dataGridView1.Rows[i].Cells[1].Value) == 88)
                                    {
                                        if (Convert.ToString(parentForm.dataGridView1.Rows[i].Cells[3].Value) == cmbStoreCode.Text & Convert.ToInt64(parentForm.dataGridView1.Rows[i].Cells[4].Value) == Convert.ToInt64(richtxtStoreCreditID.Text.Trim()))
                                        {
                                            MyMessageBox.ShowBox("DUPLICATED STORE CREDIT ID", "ERROR");
                                            richtxtStoreCreditID.SelectAll();
                                            richtxtStoreCreditID.Focus();
                                            return;
                                        }
                                    }
                                }

                                cmd.Connection  = parentForm.newConn_StoreCredit;
                                cmd.CommandText = "Show_StoreCredit_Balance";
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.Clear();
                                cmd.Parameters.Add("@StoreCreditID", SqlDbType.BigInt).Value = storeCreditID;
                                cmd.Parameters.Add("@StoreCode", SqlDbType.NVarChar).Value   = cmbStoreCode.Text;
                                SqlParameter Balance_Param = cmd.Parameters.Add("@Balance", SqlDbType.Money);
                                Balance_Param.Direction = ParameterDirection.Output;

                                parentForm.newConn_StoreCredit.Open();
                                cmd.ExecuteNonQuery();
                                parentForm.newConn_StoreCredit.Close();

                                if (cmd.Parameters["@Balance"].Value == DBNull.Value)
                                {
                                    MyMessageBox.ShowBox("COULD NOT FOUND STORE CREDIT ID", "ERROR");
                                    richtxtStoreCreditID.SelectAll();
                                    richtxtStoreCreditID.Focus();
                                }
                                else if (Convert.ToDouble(cmd.Parameters["@Balance"].Value) <= 0)
                                {
                                    MyMessageBox.ShowBox("YOUR BALANCE IS 0", "ERROR");
                                    richtxtStoreCreditID.SelectAll();
                                    richtxtStoreCreditID.Focus();
                                }
                                else
                                {
                                    balance = Convert.ToDouble(cmd.Parameters["@Balance"].Value);
                                    lblCurrentBalance.Text = string.Format("{0:c}", balance);

                                    if (balance >= storeCreditPayAmount)
                                    {
                                        richtxtStoreCreditID.Enabled = false;
                                        cmbStoreCode.Enabled         = false;
                                        btnCheckOut.Enabled          = true;
                                    }
                                    else
                                    {
                                        MyMessageBox.ShowBox("NOT ENOUGH STORE CREDIT", "ERROR");
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                MyMessageBox.ShowBox("INVALID STORE CREDIT ID", "ERROR");
                                richtxtStoreCreditID.SelectAll();
                                richtxtStoreCreditID.Focus();
                            }
                        }
                        catch
                        {
                            if (parentForm.newConn_StoreCredit.State == ConnectionState.Open)
                            {
                                parentForm.newConn_StoreCredit.Close();
                            }

                            MyMessageBox.ShowBox(cmbStoreCode.Text + " CONNECTION", "ERROR");
                            richtxtStoreCreditID.SelectAll();
                            richtxtStoreCreditID.Focus();
                        }
                    }
                }
                else
                {
                    if (Int64.TryParse(richtxtStoreCreditID.Text, out storeCreditID))
                    {
                        //Store Credit Double Check
                        for (int i = 0; i < parentForm.dataGridView1.RowCount; i++)
                        {
                            if (Convert.ToInt16(parentForm.dataGridView1.Rows[i].Cells[1].Value) == 88)
                            {
                                if (Convert.ToString(parentForm.dataGridView1.Rows[i].Cells[3].Value) == cmbStoreCode.Text & Convert.ToInt64(parentForm.dataGridView1.Rows[i].Cells[4].Value) == Convert.ToInt64(richtxtStoreCreditID.Text.Trim()))
                                {
                                    MyMessageBox.ShowBox("DUPLICATED STORE CREDIT ID", "ERROR");
                                    richtxtStoreCreditID.SelectAll();
                                    richtxtStoreCreditID.Focus();
                                    return;
                                }
                            }
                        }

                        cmd.Connection  = parentForm.parentForm.conn;
                        cmd.CommandText = "Show_StoreCredit_Balance";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@StoreCreditID", SqlDbType.BigInt).Value = storeCreditID;
                        cmd.Parameters.Add("@StoreCode", SqlDbType.NVarChar).Value   = parentForm.parentForm.storeCode;
                        SqlParameter Balance_Param = cmd.Parameters.Add("@Balance", SqlDbType.Money);
                        Balance_Param.Direction = ParameterDirection.Output;

                        parentForm.parentForm.conn.Open();
                        cmd.ExecuteNonQuery();
                        parentForm.parentForm.conn.Close();

                        if (cmd.Parameters["@Balance"].Value == DBNull.Value)
                        {
                            MyMessageBox.ShowBox("COULD NOT FOUND STORE CREDIT ID", "ERROR");
                            richtxtStoreCreditID.SelectAll();
                            richtxtStoreCreditID.Focus();
                        }
                        else if (Convert.ToDouble(cmd.Parameters["@Balance"].Value) <= 0)
                        {
                            MyMessageBox.ShowBox("YOUR BALANCE IS 0", "ERROR");
                            richtxtStoreCreditID.SelectAll();
                            richtxtStoreCreditID.Focus();
                        }
                        else
                        {
                            balance = Convert.ToDouble(cmd.Parameters["@Balance"].Value);
                            lblCurrentBalance.Text = "$" + Convert.ToString(balance);

                            if (balance >= storeCreditPayAmount)
                            {
                                richtxtStoreCreditID.Enabled = false;
                                cmbStoreCode.Enabled         = false;
                                btnCheckOut.Enabled          = true;
                            }
                            else
                            {
                                MyMessageBox.ShowBox("NOT ENOUGH STORE CREDIT", "ERROR");
                                return;
                            }
                        }
                    }
                    else
                    {
                        MyMessageBox.ShowBox("INVALID STORE CREDIT ID", "ERROR");
                        richtxtStoreCreditID.SelectAll();
                        richtxtStoreCreditID.Focus();
                    }
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string        sDirPath = Application.StartupPath;
            DirectoryInfo dir      = new DirectoryInfo(sDirPath);

            FileInfo[] files;

            files = dir.GetFiles("*.temp", SearchOption.AllDirectories);

            foreach (FileInfo file in files)
            {
                if (file.Attributes == FileAttributes.ReadOnly)
                {
                    file.Attributes = FileAttributes.Normal;
                }
                file.Delete();
            }

            if (cmbStoreName.Text == "" | cmbCashRegister.Text == "" | txtEmployeeID.Text == "" | txtPsw.Text == "")
            {
                return;
            }
            else
            {
                employeeID = txtEmployeeID.Text.Trim().ToString().ToUpper();
                password   = txtPsw.Text.Trim().ToString().ToUpper();

                if (employeeID == SystemMasterUserName & password == SystemMasterPassword)
                {
                    userLevel = 7;

                    storeName    = cmbStoreName.Text.Trim().ToString().ToUpper();
                    cashRegister = cmbCashRegister.Text.Trim().ToString().ToUpper();

                    this.Hide();
                    this.Visible = false;

                    MyMessageBox.ShowBox("CURRENT SYSTEM CLOCK\n" + DateTime.Now.ToString(), "INFORMATION");

                    MainForm mainForm = new MainForm(cashRegister, employeeID, serverConnectionString);
                    mainForm.parentForm = this;
                    mainForm.ShowDialog();
                }
                else
                {
                    SqlCommand cmd = new SqlCommand("Get_User_LogIn_Info", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@empLoginID", SqlDbType.NVarChar).Value  = employeeID.ToUpper().ToString();
                    cmd.Parameters.Add("@empPassword", SqlDbType.NVarChar).Value = password;
                    SqlParameter UserName_Param  = cmd.Parameters.Add("@empFirstName", SqlDbType.NVarChar, 50);
                    SqlParameter UserLevel_Param = cmd.Parameters.Add("@empAccessLv", SqlDbType.TinyInt);
                    UserName_Param.Direction  = ParameterDirection.Output;
                    UserLevel_Param.Direction = ParameterDirection.Output;

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();

                    if (cmd.Parameters["@empFirstName"].Value == DBNull.Value)
                    {
                        MyMessageBox.ShowBox("INVALID ACCOUNT", "ERROR");
                        txtPsw.SelectAll();
                        txtPsw.Focus();
                    }
                    else
                    {
                        userLevel = Convert.ToInt16(cmd.Parameters["@empAccessLv"].Value);

                        storeName    = cmbStoreName.Text.Trim().ToString().ToUpper();
                        cashRegister = cmbCashRegister.Text.Trim().ToString().ToUpper();

                        this.Hide();
                        this.Visible = false;

                        MyMessageBox.ShowBox("CURRENT SYSTEM CLOCK\n" + DateTime.Now.ToString(), "INFORMATION");

                        MainForm mainForm = new MainForm(cashRegister, employeeID, serverConnectionString);
                        mainForm.parentForm = this;
                        mainForm.ShowDialog();
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the cmbStoreName control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void cmbStoreName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (cmbStoreName.Text == "TEMPLE HILLS")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "OXON HILL")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "UPPER MARLBORO")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "CAPITOL HEIGHTS")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "WINDSOR MILL")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "CATONSVILLE")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "PRINCE WILLIAM")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "WOODBRIDGE")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "WALDORF")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }

                else if (cmbStoreName.Text == "GAITHERSBURG")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "BOWIE")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else if (cmbStoreName.Text == "TEST")
                {
                    serverConnectionString = "";
                    conn = new SqlConnection(serverConnectionString);
                }
                else
                {
                    MyMessageBox.ShowBox("INVALID STORE NAME", "ERROR");
                    return;
                }

                SqlDataReader  dReader;
                SqlDataAdapter adapt1 = new SqlDataAdapter();
                SqlDataAdapter adapt2 = new SqlDataAdapter();
                SqlDataAdapter adapt3 = new SqlDataAdapter();
                SqlDataAdapter adapt4 = new SqlDataAdapter();
                SqlDataAdapter adapt5 = new SqlDataAdapter();
                SqlDataAdapter adapt6 = new SqlDataAdapter();
                SqlDataAdapter adapt7 = new SqlDataAdapter();
                DataTable      dt1    = new DataTable();
                DataTable      dt2    = new DataTable();
                DataTable      dt3    = new DataTable();
                DataTable      dt4    = new DataTable();
                DataTable      dt5    = new DataTable();
                DataTable      dt6    = new DataTable();
                DataTable      dt7    = new DataTable();
                cmd1             = new SqlCommand("Select Distinct empLoginID From Employee Where empStatus='True' Order By empLoginID Asc", conn);
                cmd1.CommandType = CommandType.Text;
                cmd2             = new SqlCommand("Loading_StoreBasicSetup", conn);
                cmd2.CommandType = CommandType.StoredProcedure;
                cmd2.Parameters.Add("@StoreName", SqlDbType.NVarChar).Value = cmbStoreName.Text.Trim().ToUpper();
                cmd3             = new SqlCommand("Loading_ShortcutKey", conn);
                cmd3.CommandType = CommandType.StoredProcedure;
                cmd4             = new SqlCommand("Loading_HardwareSetup", conn);
                cmd4.CommandType = CommandType.StoredProcedure;
                cmd5             = new SqlCommand("Loading_CompanySetup", conn);
                cmd5.CommandType = CommandType.StoredProcedure;
                cmd6             = new SqlCommand("Loading_CustomerDisplayMsg", conn);
                cmd6.CommandType = CommandType.StoredProcedure;
                cmd7             = new SqlCommand("Loading_ConnectionInfo", conn);
                cmd7.CommandType = CommandType.StoredProcedure;
                cmd8             = new SqlCommand("Loading_AdminOption", conn);
                cmd8.CommandType = CommandType.StoredProcedure;

                conn.Open();
                dReader = cmd1.ExecuteReader();
                if (dReader.HasRows == true)
                {
                    while (dReader.Read())
                    {
                        namesCollection.Add(dReader["empLoginID"].ToString());
                    }
                }
                else
                {
                    MyMessageBox.ShowBox("ACTIVE EMPLOYEE NOT FOUND", "ERROR");
                }
                dReader.Close();
                adapt1.SelectCommand = cmd2;
                adapt2.SelectCommand = cmd3;
                adapt3.SelectCommand = cmd4;
                adapt4.SelectCommand = cmd5;
                adapt5.SelectCommand = cmd6;
                adapt6.SelectCommand = cmd7;
                adapt7.SelectCommand = cmd8;
                adapt1.Fill(dt1);
                adapt2.Fill(dt2);
                adapt3.Fill(dt3);
                adapt4.Fill(dt4);
                adapt5.Fill(dt5);
                adapt6.Fill(dt6);
                adapt7.Fill(dt7);
                conn.Close();

                txtEmployeeID.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
                txtEmployeeID.AutoCompleteSource       = AutoCompleteSource.CustomSource;
                txtEmployeeID.AutoCompleteCustomSource = namesCollection;

                dataGridView1.DataSource = dt1;
                dataGridView2.DataSource = dt2;
                dataGridView3.DataSource = dt3;
                dataGridView4.DataSource = dt4;
                dataGridView5.DataSource = dt5;
                dataGridView6.DataSource = dt6;
                dataGridView7.DataSource = dt7;

                storeName               = cmbStoreName.Text.Trim().ToUpper();
                LRStoreCode             = Convert.ToString(dataGridView1.Rows[0].Cells[1].Value);
                LRStoreStreet           = Convert.ToString(dataGridView1.Rows[0].Cells[2].Value);
                LRStoreCity             = Convert.ToString(dataGridView1.Rows[0].Cells[3].Value);
                LRStoreState            = Convert.ToString(dataGridView1.Rows[0].Cells[4].Value);
                LRStoreZipCode          = Convert.ToString(dataGridView1.Rows[0].Cells[5].Value);
                LRStoreTelephone        = Convert.ToString(dataGridView1.Rows[0].Cells[6].Value);
                LRStoreStreetMargin     = Convert.ToInt16(dataGridView1.Rows[0].Cells[7].Value);
                LRStoreCityStateMargin  = Convert.ToInt16(dataGridView1.Rows[0].Cells[8].Value);
                LRStoreTelephoneMargin  = Convert.ToInt16(dataGridView1.Rows[0].Cells[9].Value);
                LRStoreTaxRate          = Convert.ToDouble(dataGridView1.Rows[0].Cells[10].Value);
                LRStorePcChargePath     = Convert.ToString(dataGridView1.Rows[0].Cells[11].Value);
                LRStoreProcessor        = Convert.ToString(dataGridView1.Rows[0].Cells[12].Value);
                LRStoreMerchantNum      = Convert.ToString(dataGridView1.Rows[0].Cells[13].Value);
                LRStorePcChargeUser1    = Convert.ToString(dataGridView1.Rows[0].Cells[14].Value);
                LRStorePcChargeUser2    = Convert.ToString(dataGridView1.Rows[0].Cells[15].Value);
                LRStorePcChargeUser3    = Convert.ToString(dataGridView1.Rows[0].Cells[16].Value);
                LRStorePcChargeUser4    = Convert.ToString(dataGridView1.Rows[0].Cells[17].Value);
                LRStorePcChargeLoginID  = Convert.ToString(dataGridView1.Rows[0].Cells[18].Value).Trim();
                LRStorePcChargePassword = Convert.ToString(dataGridView1.Rows[0].Cells[19].Value).Trim();

                LRF1  = Convert.ToString(dataGridView2.Rows[0].Cells[0].Value);
                LRF2  = Convert.ToString(dataGridView2.Rows[0].Cells[1].Value);
                LRF3  = Convert.ToString(dataGridView2.Rows[0].Cells[2].Value);
                LRF4  = Convert.ToString(dataGridView2.Rows[0].Cells[3].Value);
                LRF5  = Convert.ToString(dataGridView2.Rows[0].Cells[4].Value);
                LRF6  = Convert.ToString(dataGridView2.Rows[0].Cells[5].Value);
                LRF7  = Convert.ToString(dataGridView2.Rows[0].Cells[6].Value);
                LRF8  = Convert.ToString(dataGridView2.Rows[0].Cells[7].Value);
                LRF9  = Convert.ToString(dataGridView2.Rows[0].Cells[8].Value);
                LRF10 = Convert.ToString(dataGridView2.Rows[0].Cells[9].Value);
                LRF11 = Convert.ToString(dataGridView2.Rows[0].Cells[10].Value);
                LRF12 = Convert.ToString(dataGridView2.Rows[0].Cells[11].Value);

                HWReceiptPrinterName = Convert.ToString(dataGridView3.Rows[0].Cells[2].Value);
                HWVFDCmdType         = Convert.ToString(dataGridView3.Rows[0].Cells[4].Value);
                HWVFDPort            = Convert.ToString(dataGridView3.Rows[0].Cells[6].Value);
                HWVFDBaudRate        = Convert.ToInt16(dataGridView3.Rows[0].Cells[7].Value);

                CSComapnyName        = Convert.ToString(dataGridView4.Rows[0].Cells[0].Value);
                CSReceiptLastComment = Convert.ToString(dataGridView4.Rows[0].Cells[1].Value);

                CDMOpeningMsg1 = Convert.ToString(dataGridView5.Rows[0].Cells[0].Value);
                CDMOpeningMsg2 = Convert.ToString(dataGridView5.Rows[0].Cells[1].Value);
                CDMClosingMsg1 = Convert.ToString(dataGridView5.Rows[0].Cells[2].Value);
                CDMClosingMSG2 = Convert.ToString(dataGridView5.Rows[0].Cells[3].Value);

                B4UHQIP = Convert.ToString(dataGridView6.Rows[0].Cells[4].Value);
                //B4UWHIP = Convert.ToString(dataGridView6.Rows[1].Cells[4].Value);
                THIP = Convert.ToString(dataGridView6.Rows[2].Cells[4].Value);
                OHIP = Convert.ToString(dataGridView6.Rows[3].Cells[4].Value);
                UMIP = Convert.ToString(dataGridView6.Rows[4].Cells[4].Value);
                CHIP = Convert.ToString(dataGridView6.Rows[5].Cells[4].Value);
                WMIP = Convert.ToString(dataGridView6.Rows[6].Cells[4].Value);
                CVIP = Convert.ToString(dataGridView6.Rows[7].Cells[4].Value);
                PWIP = Convert.ToString(dataGridView6.Rows[8].Cells[4].Value);
                WBIP = Convert.ToString(dataGridView6.Rows[9].Cells[4].Value);
                WDIP = Convert.ToString(dataGridView6.Rows[10].Cells[4].Value);
                GBIP = Convert.ToString(dataGridView6.Rows[11].Cells[4].Value);
                BWIP = Convert.ToString(dataGridView6.Rows[12].Cells[4].Value);

                B4UHQDB = Convert.ToString(dataGridView6.Rows[0].Cells[5].Value);
                //B4UWHDB = Convert.ToString(dataGridView6.Rows[1].Cells[5].Value);
                THDB = Convert.ToString(dataGridView6.Rows[2].Cells[5].Value);
                OHDB = Convert.ToString(dataGridView6.Rows[3].Cells[5].Value);
                UMDB = Convert.ToString(dataGridView6.Rows[4].Cells[5].Value);
                CHDB = Convert.ToString(dataGridView6.Rows[5].Cells[5].Value);
                WMDB = Convert.ToString(dataGridView6.Rows[6].Cells[5].Value);
                CVDB = Convert.ToString(dataGridView6.Rows[7].Cells[5].Value);
                PWDB = Convert.ToString(dataGridView6.Rows[8].Cells[5].Value);
                WBDB = Convert.ToString(dataGridView6.Rows[9].Cells[5].Value);
                WDDB = Convert.ToString(dataGridView6.Rows[10].Cells[5].Value);
                GBDB = Convert.ToString(dataGridView6.Rows[11].Cells[5].Value);
                BWDB = Convert.ToString(dataGridView6.Rows[12].Cells[5].Value);

                DBUID   = Convert.ToString(dataGridView6.Rows[0].Cells[6].Value);
                DBPSW   = Convert.ToString(dataGridView6.Rows[0].Cells[7].Value);
                sqlPort = Convert.ToString(dataGridView6.Rows[0].Cells[8].Value);

                SystemMasterUserName = Convert.ToString(dataGridView7.Rows[0].Cells[6].Value);
                SystemMasterPassword = Convert.ToString(dataGridView7.Rows[0].Cells[7].Value);

                B4UHQCS = "Data Source=" + B4UHQIP + ", " + sqlPort + ";Network Library=DBMSSOCN;Initial Catalog=" + B4UHQDB + ";User ID=" + DBUID + ";Password="******"CAN NOT CONNECT THE SERVER...", "ERROR");
                cmbStoreName.SelectAll();
                cmbStoreName.Focus();
            }
        }
コード例 #11
0
        /// <summary>
        /// Handles the Click event of the btnPrintClosingRegister control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnPrintClosingRegister_Click(object sender, EventArgs e)
        {
            if (txtDate.Text == "")
            {
                MyMessageBox.ShowBox("INPUT DATE", "ERROR");
                txtDate.Select();
                txtDate.Focus();
                return;
            }
            else
            {
                if (DateTime.TryParse(txtDate.Text.Trim(), out d))
                {
                    cmd             = new SqlCommand("Get_ClosingRegister_Information", parentForm.conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("@RegisterNum", SqlDbType.NVarChar).Value = parentForm.cashRegisterNum.ToUpper();
                    cmd.Parameters.Add("@RegDate", SqlDbType.NVarChar).Value     = string.Format("{0:MM/dd/yyyy}", d);
                    SqlParameter CheckNum_Param           = cmd.Parameters.Add("@CheckNum", SqlDbType.TinyInt);
                    SqlParameter TransactionID_Param      = cmd.Parameters.Add("@TransactionID", SqlDbType.BigInt);
                    SqlParameter RegStartAmount_Param     = cmd.Parameters.Add("@RegStartAmount", SqlDbType.Money);
                    SqlParameter RegCashSalesAmount_Param = cmd.Parameters.Add("@RegCashSalesAmount", SqlDbType.Money);
                    SqlParameter RegCashRealAmount_Param  = cmd.Parameters.Add("@RegCashRealAmount", SqlDbType.Money);
                    SqlParameter RegWithdrawAmount_Param  = cmd.Parameters.Add("@RegWithdrawAmount", SqlDbType.Money);
                    SqlParameter RegShortageAmount_Param  = cmd.Parameters.Add("@RegShortageAmount", SqlDbType.Money);
                    SqlParameter RegTime_Param            = cmd.Parameters.Add("@RegTime", SqlDbType.NVarChar, 50);
                    SqlParameter RegCashierID_Param       = cmd.Parameters.Add("@RegCashierID", SqlDbType.NVarChar, 50);
                    SqlParameter RegManagerID_Param       = cmd.Parameters.Add("@RegManagerID", SqlDbType.NVarChar, 50);
                    CheckNum_Param.Direction           = ParameterDirection.Output;
                    TransactionID_Param.Direction      = ParameterDirection.Output;
                    RegStartAmount_Param.Direction     = ParameterDirection.Output;
                    RegCashSalesAmount_Param.Direction = ParameterDirection.Output;
                    RegCashRealAmount_Param.Direction  = ParameterDirection.Output;
                    RegWithdrawAmount_Param.Direction  = ParameterDirection.Output;
                    RegShortageAmount_Param.Direction  = ParameterDirection.Output;
                    RegTime_Param.Direction            = ParameterDirection.Output;
                    RegCashierID_Param.Direction       = ParameterDirection.Output;
                    RegManagerID_Param.Direction       = ParameterDirection.Output;

                    parentForm.conn.Open();
                    cmd.ExecuteNonQuery();
                    parentForm.conn.Close();

                    if (Convert.ToInt16(cmd.Parameters["@CheckNum"].Value) != 0)
                    {
                        TransactionID      = Convert.ToInt64(cmd.Parameters["@TransactionID"].Value);
                        regStartAmount     = Convert.ToDouble(cmd.Parameters["@RegStartAmount"].Value);
                        regCashSalesAmount = Convert.ToDouble(cmd.Parameters["@RegCashSalesAmount"].Value);
                        regCashRealAmount  = Convert.ToDouble(cmd.Parameters["@RegCashRealAmount"].Value);
                        regWithdrawAmount  = Convert.ToDouble(cmd.Parameters["@RegWithdrawAmount"].Value);
                        regShortageAmount  = Convert.ToDouble(cmd.Parameters["@RegShortageAmount"].Value);
                        regDate            = string.Format("{0:MM/dd/yyyy}", d);
                        regTime            = Convert.ToString(cmd.Parameters["@RegTime"].Value);
                        regCashierID       = Convert.ToString(cmd.Parameters["@RegCashierID"].Value);
                        regManagerID       = Convert.ToString(cmd.Parameters["@RegManagerID"].Value);

                        Int32  retVal;
                        String errMsg;
                        apiAlias.StatusMonitoring pMonitorCB = new apiAlias.StatusMonitoring(StatusMonitoring);

                        pdPrint            = new PrintDocument();
                        pdPrint.PrintPage += new PrintPageEventHandler(pdPrint_PrintPage);
                        pdPrint.PrinterSettings.PrinterName = parentForm.PRINTER_NAME;

                        try
                        {
                            // Open Printer Monitor of Status API.
                            mpHandle = apiAlias.BiOpenMonPrinter(apiAlias.TYPE_PRINTER, pdPrint.PrinterSettings.PrinterName);
                            if (mpHandle < 0)
                            {
                                MessageBox.Show("Failed to open printer status monitor.", "", MessageBoxButtons.OK);
                            }
                            else
                            {
                                isFinish  = false;
                                cancelErr = false;

                                // Set the callback function that will monitor printer status.
                                retVal = apiAlias.BiSetStatusBackFunction(mpHandle, pMonitorCB);

                                if (retVal != apiAlias.SUCCESS)
                                {
                                    MessageBox.Show("Failed to set callback function.", "", MessageBoxButtons.OK);
                                }
                                else
                                {
                                    // Start printing.
                                    //pdPrint1.Print();
                                    //pdPrint2.Print();

                                    // Wait until callback function will say that the task is done.
                                    // When done, end the monitoring of printer status.
                                    //do
                                    //{
                                    //    if (isFinish)
                                    //        retVal = apiAlias.BiCancelStatusBack(mpHandle);
                                    //} while (!isFinish);

                                    // Display the status/error message.
                                    //DisplayStatusMessage();

                                    // If an error occurred, restore the recoverable error.
                                    if (cancelErr)
                                    {
                                        retVal = apiAlias.BiCancelError(mpHandle);
                                    }
                                    else
                                    {
                                        pdPrint.Print();
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            errMsg = ex.Message;
                            MessageBox.Show("Failed to open StatusAPI.", "", MessageBoxButtons.OK);
                        }
                        finally
                        {
                            // Close Printer Monitor.
                            if (mpHandle > 0)
                            {
                                if (apiAlias.BiCloseMonPrinter(mpHandle) != apiAlias.SUCCESS)
                                {
                                    MessageBox.Show("Failed to close printer status monitor.", "", MessageBoxButtons.OK);
                                }
                            }
                        }
                    }
                    else
                    {
                        MyMessageBox.ShowBox("NOT YET CLOSED", "ERROR");
                        txtDate.SelectAll();
                        txtDate.Focus();
                        return;
                    }
                }
                else
                {
                    MyMessageBox.ShowBox("INVALID DATE", "ERROR");
                    txtDate.SelectAll();
                    txtDate.Focus();
                    return;
                }
            }
        }
コード例 #12
0
ファイル: GiftcardRedeem.cs プロジェクト: prix79/B4U_POS
        /// <summary>
        /// Handles the Click event of the btnRedeem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnRedeem_Click(object sender, EventArgs e)
        {
            if (parentForm.dataGridView1.RowCount == 0)
            {
                MyMessageBox.ShowBox("NO ITEM", "ERROR");
                return;
            }

            if (currentBalance > 0 & parentForm.calSubTotal > 0)
            {
                if (radioBtnInputAmount.Checked == true)
                {
                    if (double.TryParse(txtInputAmount.Text, out inputAmount))
                    {
                        if (inputAmount == 0)
                        {
                            return;
                        }

                        if (inputAmount > currentBalance)
                        {
                            MyMessageBox.ShowBox("INPUT AMOUNT EXCEEDS CURRENT BALANCE", "ERROR");
                            txtInputAmount.SelectAll();
                            txtInputAmount.Focus();
                            return;
                        }
                        else
                        {
                            redeemAmount = inputAmount;
                            parentForm.giftcardRedeem    = redeemAmount;
                            parentForm.giftcardCodeDesc  = giftCardCode;
                            parentForm.giftcardStoreCode = cmbStoreCode.Text.ToUpper();
                            parentForm.richTxtUpc.Text   = "000000999111";
                            parentForm.btnInput_Click(null, null);

                            parentForm.Enabled = true;
                            this.Close();
                            parentForm.richTxtUpc.Select();
                            parentForm.richTxtUpc.Focus();
                        }
                    }
                    else
                    {
                        MyMessageBox.ShowBox("INVALID AMOUNT", "ERROR");
                        txtInputAmount.SelectAll();
                        txtInputAmount.Focus();
                        return;
                    }
                }
                else if (radioBtnAllAmount.Checked == true)
                {
                    redeemAmount = currentBalance;
                    parentForm.giftcardRedeem    = redeemAmount;
                    parentForm.giftcardCodeDesc  = giftCardCode;
                    parentForm.giftcardStoreCode = cmbStoreCode.Text.ToUpper();
                    parentForm.richTxtUpc.Text   = "000000999111";
                    parentForm.btnInput_Click(null, null);

                    parentForm.Enabled = true;
                    this.Close();
                    parentForm.richTxtUpc.Select();
                    parentForm.richTxtUpc.Focus();
                }
            }
            else
            {
                txtGiftCardCode.SelectAll();
                txtGiftCardCode.Focus();
            }
        }
コード例 #13
0
ファイル: GiftcardRedeem.cs プロジェクト: prix79/B4U_POS
        /// <summary>
        /// Handles the Click event of the btnInput control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnInput_Click(object sender, EventArgs e)
        {
            if (txtGiftCardCode.Text == "")
            {
                MyMessageBox.ShowBox("INPUT GIFTCARD CODE", "ERROR");
                txtGiftCardCode.Select();
                txtGiftCardCode.Focus();
            }
            else
            {
                lblCurrentBalance.Text = "";

                if (parentForm.storeCode != cmbStoreCode.Text)
                {
                    newConn      = new SqlConnection(parentForm.parentForm.OtherStoreConnectionString(cmbStoreCode.Text));
                    giftCardCode = txtGiftCardCode.Text.ToString().ToUpper().Trim();

                    try
                    {
                        cmd             = new SqlCommand("Get_Giftcard_Balance", newConn);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@GiftCardCode", SqlDbType.NVarChar).Value = giftCardCode;
                        SqlParameter GiftcardBalance_Param = cmd.Parameters.Add("@Balance", SqlDbType.Money);
                        GiftcardBalance_Param.Direction = ParameterDirection.Output;

                        newConn.Open();
                        cmd.ExecuteNonQuery();
                        newConn.Close();

                        if (cmd.Parameters["@Balance"].Value != DBNull.Value)
                        {
                            currentBalance          = Convert.ToDouble(cmd.Parameters["@Balance"].Value);
                            txtGiftCardCode.Enabled = false;
                            btnInput.Enabled        = false;
                            cmbStoreCode.Enabled    = false;
                            lblCurrentBalance.Text  = string.Format("{0:$0.00}", currentBalance);

                            if (currentBalance == 0)
                            {
                                MyMessageBox.ShowBox("THIS GIFTCARD BALANCE IS 0", "INFORMATION");
                            }
                        }
                        else
                        {
                            MyMessageBox.ShowBox("CAN NOT FIND GIFTCARD", "ERROR");
                            txtGiftCardCode.SelectAll();
                            txtGiftCardCode.Focus();
                            return;
                        }
                    }
                    catch
                    {
                        MyMessageBox.ShowBox("DUPLICATED GIFTCARD CODE OR SERVER CONNECT FAILED", "ERROR");
                        newConn.Close();
                        txtGiftCardCode.SelectAll();
                        txtGiftCardCode.Focus();
                        return;
                    }
                }
                else
                {
                    giftCardCode = txtGiftCardCode.Text.ToString().ToUpper().Trim();

                    try
                    {
                        cmd             = new SqlCommand("Get_Giftcard_Balance", parentForm.conn);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@GiftCardCode", SqlDbType.NVarChar).Value = giftCardCode;
                        SqlParameter GiftcardBalance_Param = cmd.Parameters.Add("@Balance", SqlDbType.Money);
                        GiftcardBalance_Param.Direction = ParameterDirection.Output;

                        parentForm.conn.Open();
                        cmd.ExecuteNonQuery();
                        parentForm.conn.Close();

                        if (cmd.Parameters["@Balance"].Value != DBNull.Value)
                        {
                            currentBalance          = Convert.ToDouble(cmd.Parameters["@Balance"].Value);
                            txtGiftCardCode.Enabled = false;
                            btnInput.Enabled        = false;
                            cmbStoreCode.Enabled    = false;
                            lblCurrentBalance.Text  = string.Format("{0:$0.00}", currentBalance);

                            if (currentBalance == 0)
                            {
                                MyMessageBox.ShowBox("THIS GIFTCARD BALANCE IS 0", "INFORMATION");
                            }
                        }
                        else
                        {
                            MyMessageBox.ShowBox("CAN NOT FIND GIFTCARD", "ERROR");
                            txtGiftCardCode.SelectAll();
                            txtGiftCardCode.Focus();
                            return;
                        }
                    }
                    catch
                    {
                        MyMessageBox.ShowBox("DUPLICATED GIFTCARD CODE OR SERVER CONNECT FAILED", "ERROR");
                        parentForm.conn.Close();
                        txtGiftCardCode.SelectAll();
                        txtGiftCardCode.Focus();
                        return;
                    }
                }
            }
        }