Пример #1
0
        private void dgvItems_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int ItemId = Convert.ToInt32(dgvItems.Rows[e.RowIndex].Cells[0].Value);

                Item item = ItemFactory.Create();
                item.ItemId        = ItemId;
                item.ItemName      = dgvItems.Rows[e.RowIndex].Cells[1].Value.ToString();
                item.Description   = dgvItems.Rows[e.RowIndex].Cells[2].Value.ToString();
                item.Quantity      = Convert.ToInt32(dgvItems.Rows[e.RowIndex].Cells[3].Value);
                item.Price         = Convert.ToInt32(dgvItems.Rows[e.RowIndex].Cells[4].Value);
                item.Location      = dgvItems.Rows[e.RowIndex].Cells[5].Value.ToString();
                item.Justification = dgvItems.Rows[e.RowIndex].Cells[6].Value.ToString();

                CUDMethods.UpdateItem(item);

                po               = POFactory.Create(Convert.ToInt32(dgvItems.Rows[e.RowIndex].Cells[8].Value));
                lblSubNum.Text   = "$ " + po.Total.ToString("F");
                lblTaxNum.Text   = "$ " + (po.Total * 0.15).ToString("F");
                lblTotalNum.Text = "$ " + (po.Total * 1.15).ToString("F");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        protected void lstOrders_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstOrders.SelectedIndex >= 0)
            {
                po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
                List <Employee> emp = EmployeeFactory.RetrieveEmployeesByID(po.EmpId);
                LoadItems();
                lblOrderNumber.Text  = po.OrderNumber.ToString();
                lblDate.Text         = po.OrderDate.ToShortDateString();
                lblTotal.Text        = "$" + po.Total.ToString();
                lblOrderStatus.Text  = po.OrderStatus.ToString();
                lblEmpNameOrder.Text = emp[0].FullName;

                lblModLocation.Visible = false;
                lblModPrice.Visible    = false;
                lblModQty.Visible      = false;
                lblModReason.Visible   = false;
                txtModLocation.Visible = false;
                txtModPrice.Visible    = false;
                txtModQty.Visible      = false;
                txtModReason.Visible   = false;
                btnModApprove.Visible  = false;
                btnApprove.Visible     = false;
                btnDeny.Visible        = false;
                btnMod.Visible         = false;
                btnClose.Visible       = false;
            }
        }
Пример #3
0
        private void txtEnterOrder_TextChanged(object sender, EventArgs e)
        {
            try
            {
                lblOrderNumber.Text = txtEnterOrder.Text;
                po = POFactory.Create(Convert.ToInt32(lblOrderNumber.Text));

                lblSubNum.Text   = "$" + (po.Total).ToString("F");
                lblTaxNum.Text   = "$" + (po.Total * 0.15).ToString("F");
                lblTotalNum.Text = "$" + (po.Total * 1.15).ToString("F");
                orderPrice       = po.Total;

                foreach (Item item in po.Items)
                {
                    lstItems.Items.Add(item.ItemName);
                }
            }
            catch
            {
                lblSubNum.Text   = "$0.00";
                lblTaxNum.Text   = "$0.00";
                lblTotalNum.Text = "$0.00";
                lstItems.Items.Clear();
            }
        }
        protected void btnDeny_Click(object sender, EventArgs e)
        {
            askToClose = true;

            CUDMethods.ProcessItem(Convert.ToInt32(Session["itemId"].ToString()), Convert.ToByte(3));
            LoadItems();;

            po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));

            foreach (Item item in po.Items)
            {
                if (item.ItemStatus == Types.ItemStatus.Pending)
                {
                    askToClose = false;
                }
                else
                {
                    CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(2));
                }
            }

            po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
            lblOrderStatus.Text = po.OrderStatus.ToString();

            if (askToClose == true)
            {
                btnClose.Visible = true;
            }
        }
        protected void grvItems_SelectedIndexChanged(object sender, EventArgs e)
        {
            grvItems.BackColor             = System.Drawing.Color.White;
            grvItems.SelectedRow.BackColor = System.Drawing.Color.LightCyan;

            Session["itemId"] = Convert.ToInt32(grvItems.SelectedRow.Cells[1].Text);

            po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));

            if (po.OrderStatus == Types.OrderStatus.Closed)
            {
                btnApprove.Visible    = false;
                btnDeny.Visible       = false;
                btnMod.Visible        = false;
                btnModApprove.Visible = false;
                btnClose.Visible      = false;
            }
            else
            {
                btnApprove.Visible = true;
                btnDeny.Visible    = true;
                btnMod.Visible     = true;
            }

            lblModLocation.Visible = false;
            lblModPrice.Visible    = false;
            lblModQty.Visible      = false;
            lblModReason.Visible   = false;
            txtModLocation.Visible = false;
            txtModPrice.Visible    = false;
            txtModQty.Visible      = false;
            txtModReason.Visible   = false;
            btnModApprove.Visible  = false;
        }
Пример #6
0
 public POCreateHandler(GlobalSolusindoDb db, tblM_User user, POValidator pOValidator, POFactory pOFactory
                        , POQuery pOQuery) : base(db, user)
 {
     this.POValidator         = pOValidator;
     this.POFactory           = pOFactory;
     this.POQuery             = pOQuery;
     this.POEntryDataProvider = new POEntryDataProvider(db, user, pOQuery);
 }
 public POImportExcelHandler(GlobalSolusindoDb db, tblM_User user, POValidator poValidator,
                             POFactory poFactory, POQuery poQuery) : base(db, user)
 {
     this.poValidator         = poValidator;
     this.poFactory           = poFactory;
     this.poQuery             = poQuery;
     this.poEntryDataProvider = new POEntryDataProvider(db, user, poQuery);
 }
Пример #8
0
 private void lstOrders_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstOrders.SelectedIndex >= 0 && lstOrders.Enabled == true)
     {
         po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
         dgvItems.DataSource = ListsItemFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
         lblSubNum.Text      = "$ " + po.Total.ToString("F");
         lblTaxNum.Text      = "$ " + (po.Total * 0.15).ToString("F");
         lblTotalNum.Text    = "$ " + (po.Total * 1.15).ToString("F");
     }
 }
Пример #9
0
 private void BindGridView()
 {
     if (lstOrders.SelectedIndex >= 0 && lstOrders.Enabled == true)
     {
         po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
         dgvItems.DataSource = ListsItemFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
         dgvItems.DataBind();
         lblSub.Text   = "Sub Total: $ " + po.Total.ToString("F");
         lblTax.Text   = "Tax: $ " + (po.Total * 0.15).ToString("F");
         lblTotal.Text = "Total: $ " + (po.Total * 1.15).ToString("F");
     }
 }
Пример #10
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                btnCreate.Text = "Add Item";

                item = ItemFactory.Create();
                po   = POFactory.Create();

                double itemPrice = Convert.ToDouble(txtPrice.Text);
                orderPrice += itemPrice;

                item.ItemName      = txtName.Text;
                item.Description   = txtDesc.Text;
                item.Quantity      = Convert.ToInt32(txtQty.Text);
                item.Price         = itemPrice;
                item.Location      = txtLocation.Text;
                item.Justification = txtJustification.Text;

                po.Items = new List <Types.IItem>();
                po.Items.Add(item);
                po.OrderNumber = Convert.ToInt32(lblOrderNumber.Text);
                po.EmpId       = emp[0].EmpID;

                int orderNumber = CUDMethods.CreatPO(po);

                lblSubNum.Text   = "$" + (orderPrice).ToString("F");
                lblTaxNum.Text   = "$" + (orderPrice * 0.15).ToString("F");
                lblTotalNum.Text = "$" + (orderPrice * 1.15).ToString("F");

                lblOrderNumber.Text         = orderNumber.ToString();
                lblOrderNumber.Visible      = true;
                lblOrderNumberLabel.Visible = true;

                if (lstItems.Items.Contains(item.ItemName))
                {
                    return;
                }
                else
                {
                    lstItems.Items.Add(item.ItemName);
                }

                clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //errorProvider1.SetError(sender, ex.Message);
            }
        }
Пример #11
0
        private void lstOrders_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstOrders.SelectedIndex >= 0 && lstOrders.Enabled == true)
            {
                po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
                LoadItems();
                lblOrderNumber.Text = po.OrderNumber.ToString();
                lblName.Text        = po.EmpId.ToString();
                lblDate.Text        = po.OrderDate.ToShortDateString();
                lblTotal.Text       = "$" + po.Total.ToString();
                lblOrderStatus.Text = po.OrderStatus.ToString();

                grpTop.Visible = true;
            }
        }
Пример #12
0
        private void btnApprove_Click(object sender, EventArgs e)
        {
            askToClose = true;

            CUDMethods.ProcessItem(Convert.ToInt32(dgvItems.CurrentRow.Cells[0].Value), Convert.ToByte(2));
            LoadItems();;

            po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));

            foreach (Item item in po.Items)
            {
                if (item.ItemStatus == Types.ItemStatus.Pending)
                {
                    askToClose = false;
                }
                else
                {
                    CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(2));
                }
            }

            po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
            lblOrderStatus.Text = po.OrderStatus.ToString();

            if (askToClose == true)
            {
                DialogResult dialogResult = MessageBox.Show("Do you want to close the order?", "Purchase Order", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(3));
                    po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
                    LoadItems();
                    lblOrderNumber.Text = po.OrderNumber.ToString();
                    lblName.Text        = po.EmpId.ToString();
                    lblDate.Text        = po.OrderDate.ToShortDateString();
                    lblTotal.Text       = "$" + po.Total.ToString();
                    lblOrderStatus.Text = po.OrderStatus.ToString();

                    sendEmail();
                }
                else if (dialogResult == DialogResult.No)
                {
                }
            }
        }
Пример #13
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                item = ItemFactory.Create();
                po   = POFactory.Create();

                double itemPrice = Convert.ToDouble(txtPrice.Text);
                orderPrice += itemPrice;

                item.ItemName      = txtName.Text;
                item.Description   = txtDesc.Text;
                item.Quantity      = Convert.ToInt32(txtQty.Text);
                item.Price         = itemPrice;
                item.Location      = txtLocation.Text;
                item.Justification = txtJustification.Text;

                po.Items = new List <Types.IItem>();
                po.Items.Add(item);
                po.OrderNumber = Convert.ToInt32(lblOrderNum.Text);
                po.EmpId       = 10000004;

                int orderNumber = CUDMethods.CreatPO(po);

                lblSubNum.Text   = "$" + (orderPrice).ToString("F");
                lblTaxNum.Text   = "$" + (orderPrice * 0.15).ToString("F");
                lblTotalNum.Text = "$" + (orderPrice * 1.15).ToString("F");

                lblOrderNum.Text    = orderNumber.ToString();
                lblOrderNum.Visible = true;
                lblOrder.Visible    = true;

                btnCreate.Text = "Add";
                lstItems.Items.Add(item.ItemName);

                clear();
                lblError.InnerText = "";
            }
            catch (Exception ex)
            {
                lblError.InnerText = "Please fill all fields correctly!";
            }
        }
Пример #14
0
        protected void btnClose_Click(object sender, EventArgs e)
        {
            po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
            CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(3));
            LoadItems();
            lblOrderNumber.Text = po.OrderNumber.ToString();
            lblDate.Text        = po.OrderDate.ToShortDateString();
            lblTotal.Text       = "$" + po.Total.ToString();
            lblOrderStatus.Text = po.OrderStatus.ToString();

            btnApprove.Visible    = false;
            btnDeny.Visible       = false;
            btnMod.Visible        = false;
            btnModApprove.Visible = false;
            btnClose.Visible      = false;

            LoadItems();
            sendEmail();
        }
Пример #15
0
        protected void dgvItems_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row = dgvItems.Rows[e.RowIndex];

                Item    item         = ItemFactory.Create();
                TextBox textId       = (TextBox)row.Cells[1].Controls[0];
                TextBox textName     = (TextBox)row.Cells[2].Controls[0];
                TextBox textDesc     = (TextBox)row.Cells[3].Controls[0];
                TextBox textQty      = (TextBox)row.Cells[4].Controls[0];
                TextBox textPrice    = (TextBox)row.Cells[5].Controls[0];
                TextBox textLocation = (TextBox)row.Cells[6].Controls[0];
                TextBox textJust     = (TextBox)row.Cells[7].Controls[0];
                TextBox textOrder    = (TextBox)row.Cells[9].Controls[0];

                item.ItemId        = Convert.ToInt32(textId.Text);
                item.ItemName      = textName.Text;
                item.Description   = textDesc.Text;
                item.Quantity      = Convert.ToInt32(textQty.Text);
                item.Price         = Convert.ToDouble(textPrice.Text);
                item.Location      = textLocation.Text;
                item.Justification = textJust.Text;

                CUDMethods.UpdateItem(item);

                po            = POFactory.Create(Convert.ToInt32(textOrder.Text));
                lblSub.Text   = "$ " + po.Total.ToString("F");
                lblTax.Text   = "$ " + (po.Total * 0.15).ToString("F");
                lblTotal.Text = "$ " + (po.Total * 1.15).ToString("F");

                dgvItems.EditIndex = -1;
                BindGridView();
                lblError.InnerText = "";
            }
            catch (Exception ex)
            {
                lblError.InnerText = ex.Message;
            }
        }
Пример #16
0
        protected void btnModApprove_Click(object sender, EventArgs e)
        {
            try
            {
                askToClose = true;
                Item i = ItemFactory.Create();

                i.ItemId        = Convert.ToInt32(grvItems.SelectedRow.Cells[1].Text);
                i.ItemName      = grvItems.SelectedRow.Cells[2].Text;
                i.Description   = grvItems.SelectedRow.Cells[3].Text;
                i.Price         = Convert.ToDouble(txtModPrice.Text);
                i.Quantity      = Convert.ToInt32(txtModQty.Text);
                i.Location      = txtModLocation.Text;
                i.Justification = grvItems.SelectedRow.Cells[7].Text;
                i.OrderNumber   = Convert.ToInt32(grvItems.SelectedRow.Cells[9].Text);
                i.ReasonForMod  = txtModReason.Text;

                if (grvItems.SelectedRow.Cells[8].Text == "Approved")
                {
                    i.ItemStatus = Types.ItemStatus.Approved;
                }
                else if (grvItems.SelectedRow.Cells[8].Text == "Denied")
                {
                    i.ItemStatus = Types.ItemStatus.Denied;
                }
                else if (grvItems.SelectedRow.Cells[8].Text == "Pending")
                {
                    i.ItemStatus = Types.ItemStatus.Pending;
                }

                if (txtModLocation.Text != "" && txtModPrice.Text != "" && txtModQty.Text != "" && txtModReason.Text != "")
                {
                    CUDMethods.ProcessItem(Convert.ToInt32(Session["itemId"].ToString()), Convert.ToByte(2));
                    CUDMethods.ModItem(i);
                }

                LoadItems();

                po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));

                foreach (Item item in po.Items)
                {
                    if (item.ItemStatus == Types.ItemStatus.Pending)
                    {
                        askToClose = false;
                    }
                    else
                    {
                        CUDMethods.ProcessOrder(po.OrderNumber, Convert.ToByte(2));
                    }
                }

                po = POFactory.Create(Convert.ToInt32(lstOrders.SelectedValue));
                lblOrderStatus.Text = po.OrderStatus.ToString();

                if (askToClose == true)
                {
                    btnClose.Visible = true;
                }

                lblModLocation.Visible = false;
                lblModPrice.Visible    = false;
                lblModQty.Visible      = false;
                lblModReason.Visible   = false;
                txtModLocation.Visible = false;
                txtModPrice.Visible    = false;
                txtModQty.Visible      = false;
                txtModReason.Visible   = false;
                btnModApprove.Visible  = false;

                lblError.InnerText = "";
            }
            catch (Exception ex)
            {
                lblError.InnerText = "Please fill all fields correctly!";
            }
        }