private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtCustomerID
            if (sender == txtCustomerID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oCustomer.View())
                    {
                        txtCustomerID.Text = oCustomer.ID;
                        oCustomer.Find(txtCustomerID.Text);
                        //txtName.Text = oCustomer.Name;
                    }
                    return;
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtCustomerID.Text.Trim().Length == 0)
                    {
                        txtCustomerID.Focus();
                    }

                    if (oCustomer.Find(txtCustomerID.Text))
                    {
                        txtCustomerID.Text = oCustomer.ID;
                        //txtName.Text = oCustomer.Name;
                    }
                }
            }
            #endregion
            #region txtBrochureID
            if (sender == txtBrochureID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oBrochure.View())
                    {
                        txtBrochureID.Text   = oBrochure.ID;
                        ctrBrochureName.Text = oBrochure.Description;
                    }
                    return;
                }
                if (e.KeyCode == Keys.Enter)
                {
                    if (txtBrochureID.Text != "")
                    {
                        if (oBrochure.Find(txtBrochureID.Text))
                        {
                            txtBrochureID.Text   = oBrochure.ID;
                            ctrBrochureName.Text = oBrochure.Description;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }
            #endregion
            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Tab:
                if (!e.Shift)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
                break;

            case Keys.Enter:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Down:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Up:
                this.SelectNextControl(this.ActiveControl, false, true, true, true);
                break;

            case Keys.F8:
                break;

            case Keys.F3:
                break;

            case Keys.F7:
                this.Close();
                break;

            case Keys.PageDown:
                oCustomer.PrintCustomerDate(txtDateFrom.Value, txtDateTo.Value, txtType.CheckedItem.DataValue.ToString(), cbLetterAprovalDone.Checked, cbNotChecked.Checked, cbCompleted.Checked, this.txtBrochureID.Text);
                this.Dispose();
                break;


                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
Beispiel #2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //   this.warpGrid.AddLinkedRequestTrigger("butAddItem");

            if (Session["CustomerID"] == null)
            {
                Response.Redirect("Default.aspx");
            }
            else
            {
                this.AddKeepAlive();

                Global.oMySql.Close(ConnectionType.Unique);
                oMySql = new MySQL(ConnectionType.NonUnique);

                oCustomer        = new Customer(Session["CompanyID"].ToString());
                oCustomer.oMySql = oMySql;
                oCustomer.Find(Session["CustomerID"].ToString());

                oCustomerCS        = new Customer.CustomerCS(oCustomer.CompanyID);
                oCustomerCS.oMySql = oMySql;
                oCustomerCS.Find(oCustomer.ID);
                oBrochure        = new Brochure(oCustomer.CompanyID);
                oBrochure.oMySql = oMySql;

                if (!this.IsPostBack)
                {
                    if (oCustomerCS.Goal == 0)
                    {
                        txtGoal.Text = "10";
                    }
                    else
                    {
                        txtGoal.Text = oCustomerCS.Goal.ToString();
                    }

                    if (oCustomerCS.EarlyBirdDate == Global.DNull)
                    {
                        txtEarlyBirdDate.Value = oCustomer.StartDate.AddDays(7);
                    }
                    else
                    {
                        txtEarlyBirdDate.Value = oCustomerCS.EarlyBirdDate.ToString("MM/dd/yyyy");
                    }
                }
                txtName.Text        = oCustomer.Name;
                txtAddress.Text     = oCustomer.Address + " " + oCustomer.City + " " + oCustomer.State + ", " + oCustomer.ZipCode;
                txtChairperson.Text = oCustomer.Chairperson;
                txteMail.Text       = oCustomer.eMail;
                txtFax.Text         = oCustomer.FaxNumber != ""? string.Format("{0:(###)-###-####}", double.Parse(oCustomer.FaxNumber)):"";
                txtPhone.Text       = oCustomer.PhoneNumber != ""?string.Format("{0:(###)-###-####}", double.Parse(oCustomer.PhoneNumber)):"";
                oBrochure.Find(oCustomer.BrochureID);
                txtBrochure.Text         = oCustomer.BrochureID + " - " + oBrochure.Description;
                txtProfit.Text           = oCustomer.ProfitPercent.ToString();
                txtStartDate.Text        = (oCustomer.StartDate == Global.DNull)?"":oCustomer.StartDate.ToString("MM/dd/yyyy");
                txtEndDate.Text          = (oCustomer.EndDate == Global.DNull) ? "" : oCustomer.EndDate.ToString("MM/dd/yyyy");
                txtPickUpDate.Text       = (oCustomer.PickUpDate == Global.DNull) ? "" : oCustomer.PickUpDate.ToString("MM/dd/yyyy");
                txtDeliveryDate.Text     = (oCustomer.DeliveryDate == Global.DNull) ? "" : oCustomer.DeliveryDate.ToString("MM/dd/yyyy");
                txtParentPickUpDate.Text = (oCustomer.ParentPickUpDate == Global.DNull) ? "" : oCustomer.ParentPickUpDate.ToString("MM/dd/yyyy");
                // txtItemsDelivery.Text = oCustomer.NoItems.ToString();

                oMySql.Dispose();
            }
        }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtBrochureID
            if (sender == txtBrochureID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oBrochure.View())
                    {
                        txtBrochureID.Text  = oBrochure.ID;
                        txtDescription.Text = oBrochure.Description;
                    }
                    return;
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtBrochureID.Text.Trim().Length == 0)
                    {
                        txtBrochureID.Focus();
                    }

                    if (oBrochure.Find(txtBrochureID.Text))
                    {
                        txtBrochureID.Text  = oBrochure.ID;
                        txtDescription.Text = oBrochure.Description;
                    }
                }
            }
            #endregion
            #region txtBrochureID_2
            if (sender == txtBrochureID_2)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oBrochure.View())
                    {
                        txtBrochureID_2.Text  = oBrochure.ID;
                        txtDescription_2.Text = oBrochure.Description;
                    }
                    return;
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtBrochureID_2.Text.Trim().Length == 0)
                    {
                        txtBrochureID_2.Focus();
                    }

                    if (oBrochure.Find(txtBrochureID_2.Text))
                    {
                        txtBrochureID_2.Text  = oBrochure.ID;
                        txtDescription_2.Text = oBrochure.Description;
                    }
                }
            }
            #endregion


            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Tab:
                if (!e.Shift)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
                break;

            case Keys.Enter:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Down:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Up:
                this.SelectNextControl(this.ActiveControl, false, true, true, true);
                break;

            case Keys.F8:
                break;

            case Keys.F3:
                break;

            case Keys.F7:
                this.Close();
                break;

            case Keys.PageDown:
                if (txtBrochureID.Text.Length > 0 && txtBrochureID_2.Text.Length > 0)
                {
                    oBrochure.Print2Brochures(txtBrochureID.Text, txtBrochureID_2.Text);
                }
                this.Dispose();
                break;


                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }
Beispiel #4
0
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtBrochureID
            if (sender == txtBrochureID)
            {
                if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.F3)
                {
                    return;
                }


                if (e.KeyCode.ToString() == "F2")
                {
                    if (oBrochure.View())
                    {
                        ShowVendor();
                    }

                    if (txtBrochureID.Text == "")
                    {
                        return;
                    }

                    txtDescription.Focus();
                    Grid.DataSource = oBrochure.Items.dtItems;
                    Grid.DataBind();
                    Grid.Focus();
                    MoveLast();
                    return;
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtBrochureID.Text.Trim().Length == 0)
                    {
                        Clear();
                        txtBrochureID.Focus();
                    }

                    if (oBrochure.Find(txtBrochureID.Text))
                    {
                        ShowVendor();
                        Grid.DataSource = oBrochure.Items.dtItems;
                        Grid.DataBind();
                        Grid.Focus();
                        MoveLast();
                    }
                    else
                    {
                        Clear();
                        oBrochure.ID = txtBrochureID.Text;
                        oBrochure.Items.AddEmpty();
                        Grid.DataSource = oBrochure.Items.dtItems;
                        Grid.DataBind();
                        txtDescription.Focus();
                    }


                    return;
                }
            }
            #endregion
            #region txtDescription
            if (sender == txtDescription)
            {
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    oBrochure.Description = txtDescription.Text;
                    Grid.Focus();
                    MoveLast();
                    return;
                }
            }
            #endregion
            #region Grid

            if (sender == Grid)
            {
                if (e.KeyCode == Keys.F2)
                {
                    UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    if (gridRow != null)
                    {
                        if (Grid.ActiveRow.Cells["ProductID"] == Grid.ActiveCell)
                        {
                            if (oProduct.View())
                            {
                                if (!Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                                {
                                    Grid.ActiveRow.Cells["ProductID"].Value   = oProduct.ID;
                                    Grid.ActiveRow.Cells["InvCode"].Value     = oProduct.InvCode;
                                    Grid.ActiveRow.Cells["Description"].Value = oProduct.Description;
                                    Grid.ActiveRow.Cells["Price"].Activate();
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                                else
                                {
                                    MessageBox.Show("Item already entered");
                                    Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                            }
                        }
                    }
                }


                if (e.KeyCode == Keys.Delete)
                {
                }


                if (e.KeyCode == Keys.Enter)
                {
                    if (Grid.ActiveRow.Cells["ProductID"].Text != "" && !Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                    {
                        if (Grid.ActiveRow.Cells["ProductID"] == Grid.ActiveCell)
                        {
                            if (oProduct.Find(Grid.ActiveRow.Cells["ProductID"].Text))
                            {
                                if (!Contain(Grid.ActiveRow.Cells["ProductID"].Text))
                                {
                                    Grid.ActiveRow.Cells["ProductID"].Value   = oProduct.ID;
                                    Grid.ActiveRow.Cells["InvCode"].Value     = oProduct.InvCode;
                                    Grid.ActiveRow.Cells["Description"].Value = oProduct.Description;
                                    Grid.ActiveRow.Cells["Price"].Activate();
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                                else
                                {
                                    MessageBox.Show("Item already entered");
                                    Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                                    Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                                    return;
                                }
                            }
                        }
                        else if (Grid.ActiveRow.Cells["Price"] == Grid.ActiveCell)
                        {
                            Grid.ActiveRow.Cells["Forecast"].Activate();
                            Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                            return;
                        }

                        if (Grid.GetRow(ChildRow.Last) == Grid.ActiveRow)
                        {
                            oBrochure.Items.AddEmpty();
                            Grid.DataBind();
                            MoveLast();
                            //Grid.PerformAction(UltraGridAction.LastRowInBand, false, false);
                        }
                        else
                        {
                            Grid.PerformAction(UltraGridAction.NextRowByTab, false, false);
                            Grid.ActiveRow.Cells["ProductID"].Activate();
                            Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        }
                    }
                    else
                    {
                        Grid.ActiveRow.Cells["ProductID"].Activate();
                        Grid.PerformAction(UltraGridAction.EnterEditMode, false, false);
                        Grid.ActiveRow.Cells["Price"].Value = 0;
                    }
                    return;
                }

                if (e.KeyCode == Keys.Down)
                {
                    MoveDown();
                    return;
                }
                if (e.KeyCode == Keys.Up)
                {
                    Infragistics.Win.UltraWinGrid.UltraGridRow gridRow;
                    gridRow = Grid.ActiveRow;
                    gridRow = gridRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Previous);
                    if (gridRow != null)
                    {
                        gridRow.Activate();
                        //' set ActiveCell
                        Grid.ActiveCell = Grid.ActiveRow.Cells["ProductID"];
                        Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
                    }
                    return;
                    //SendKeys.Send("{TAB}");
                }
            }
            #endregion
            #region txtProductID
            if (sender == txtProductID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oProduct.View())
                    {
                        txtProductID.Text    = oProduct.ID;
                        txtPDescription.Text = oProduct.Description;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtProductID.Text.Trim().Length == 0)
                    {
                        txtProductID.Focus();
                    }

                    if (oProduct.Find(txtProductID.Text))
                    {
                        txtProductID.Text    = oProduct.ID;
                        txtPDescription.Text = oProduct.Description;
                    }
                }
            }
            #endregion
            #region txtProductTypeID
            if (sender == txtProductTypeID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oPack.View())
                    {
                        txtProductTypeID.Text = oPack.ID;
                        txtPTDescription.Text = oPack.Description;
                    }
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtProductTypeID.Text.Trim().Length == 0)
                    {
                        txtProductTypeID.Focus();
                    }

                    if (oPack.Find(txtProductTypeID.Text))
                    {
                        txtProductTypeID.Text = oPack.ID;
                        txtPTDescription.Text = oPack.Description;
                    }
                }
            }
            #endregion
            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Tab:
                if (!e.Shift)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
                break;

            case Keys.Enter:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Down:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Up:
                this.SelectNextControl(this.ActiveControl, false, true, true, true);
                break;

            case Keys.F3:
                if (MessageBox.Show("Do you really want to Delete this Brochure?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    MessageBox.Show("Operation Cancelled");
                    return;
                }
                oBrochure.Delete();
                Grid.DataBind();
                Clear();
                txtBrochureID.Clear();
                txtBrochureID.Focus();

                break;

            case Keys.PageDown:
                this.Save();
                Grid.DataBind();
                Clear();
                txtBrochureID.Clear();
                txtBrochureID.Focus();
                break;

            case Keys.Delete:
                if (e.Control)
                {
                    DeleteItem();
                }
                break;
                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }