Esempio n. 1
0
 private void SupplierInvoiceForm_Load(object sender, EventArgs e)
 {
     APCContext          = new APCEntities();
     ddlPO.DataSource    = BLPO.GetAllPO(APCContext);
     ddlPO.DisplayMember = "Id";
     ddlPO.ValueMember   = "Id";
 }
Esempio n. 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                PO currentPO = BLPO.GetPOById(APCContext, id);
                if (currentPO != null)
                {
                    APCContext.DeleteObject(currentPO);
                    APCContext.SaveChanges();
                    deletePO_Product(currentPO);

                    MessageBox.Show("Delete Successfully");
                    ClearContent();
                    SetComboToDefault();
                }
                else
                {
                    MessageBox.Show("PO Id not found");
                }
            }
            else
            {
                MessageBox.Show("PO Id not found");
            }
        }
Esempio n. 3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Supplier selectedSupplier = BLSupplier.GetSupplierById(APCContext, int.Parse(cbSupplier.SelectedValue.ToString()));
            Project  selectedProject  = BLProject.GetProjectById(APCContext, int.Parse(cbProject.SelectedValue.ToString()));
            int      id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                PO currentPO = BLPO.GetPOById(APCContext, id);
                if (currentPO != null)
                {
                    currentPO.Supplier = selectedSupplier;
                    currentPO.Project  = selectedProject;
                    APCContext.SaveChanges();

                    deletePO_Product(currentPO);
                    insertPO_Product(currentPO);

                    MessageBox.Show("PO Details Successfully Updated");
                    ClearContent();
                    SetComboToDefault();
                }
                else
                {
                    MessageBox.Show("PO Id not found");
                }
            }
            else
            {
                MessageBox.Show("PO Id not found");
            }
        }
Esempio n. 4
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            Supplier selectedSupplier = BLSupplier.GetSupplierById(APCContext, int.Parse(cbSupplier.SelectedValue.ToString()));
            Project  selectedProject  = BLProject.GetProjectById(APCContext, int.Parse(cbProject.SelectedValue.ToString()));
            PO       po = BLPO.insertPO(APCContext, selectedSupplier, selectedProject);

            insertPO_Product(po);

            MessageBox.Show("PO Successfully Added");
            ClearContent();
            SetComboToDefault();
        }
Esempio n. 5
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                SupplierInvoice currentSupplierInvoice = BLSupplierInvoice.GetSupplierInvoiceById(APCContext, id);
                if (currentSupplierInvoice != null)
                {
                    decimal paymentDue = 0;
                    if (decimal.TryParse(tbPaymentDue.Text, out paymentDue))
                    {
                        if (calDueDate.Value != null)
                        {
                            if (ddlPO.SelectedValue != null)
                            {
                                currentSupplierInvoice.SupplierOriNo = tbSupplierOriInvoiceNo.Text;
                                currentSupplierInvoice.PaymentDue    = paymentDue;
                                currentSupplierInvoice.DueDate       = calDueDate.Value;
                                currentSupplierInvoice.PO            = BLPO.GetPOById(APCContext, int.Parse(ddlPO.SelectedValue.ToString()));
                                APCContext.SaveChanges();
                                MessageBox.Show("SupplierInvoice Details Successfully Updated");
                            }
                            else
                            {
                                MessageBox.Show("Please select the associated PO Number");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please specify a correct due date");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please specify correct amount of Payment Due");
                    }
                }
                else
                {
                    MessageBox.Show("SupplierInvoice Id not found");
                }
            }
            else
            {
                MessageBox.Show("SupplierInvoice Id not found");
            }
        }
Esempio n. 6
0
 private void ddlProject_SelectedValueChanged(object sender, EventArgs e)
 {
     if (((ComboBox)sender).SelectedIndex != -1)
     {
         string strProjectId = ((ComboBox)sender).SelectedValue.ToString();
         int    projectId    = 0;
         if (int.TryParse(strProjectId, out projectId))
         {
             ddlPO.DataSource    = BLPO.GetUninvoicedPOByProjectId(APCContext, projectId);
             ddlPO.DisplayMember = "Id";
             ddlPO.ValueMember   = "Id";
         }
         getDefaultDataForPOGrid();
     }
 }
Esempio n. 7
0
        private bool InsertInvoicePO(Invoice selectedInvoice)
        {
            bool      success = true;
            DataTable dtPO    = (DataTable)dgPO.DataSource;

            if (dtPO != null)
            {
                for (int i = 0; i < dtPO.Rows.Count; i++)
                {
                    PO selectedPO = BLPO.GetPOById(APCContext, int.Parse(dtPO.Rows[i]["POId"].ToString()));
                    if (!BLInvoice.insertInvoicePO(APCContext, selectedInvoice, selectedPO))
                    {
                        success = false;
                    }
                }
            }
            return(success);
        }
Esempio n. 8
0
        public List <PO> searchById(int id)
        {
            if (id != 0)
            {
                List <PO> poList = BLPO.GetPOListById(APCContext, id);

                if (poList != null)
                {
                    tbId.Text = poList[0].Id.ToString();
                    cbSupplier.SelectedValue = poList[0].Supplier.Id;
                    cbProject.SelectedValue  = poList[0].Project.Id;
                    List <PO_Product> poProductList = BLPO_Product.GetPO_ProductByPOId(APCContext, id);
                    dgPOProduct.DataSource = createPO_ProductTableFromList(poProductList);

                    dgPOProduct.Columns.Remove("Name");
                    dgPOProduct.Columns.Remove("SubCon");

                    DataGridViewComboBoxColumn colName = BLHelper.ReturnDataGridComboBoxColumn("Name", "Name", "Name", "Name");
                    colName.DataSource = APCContext.Category;

                    DataGridViewCheckBoxColumn colSubCon = BLHelper.ReturnDataGridCBColumn("SubCon");

                    dgPOProduct.Columns.Insert(0, colName);
                    dgPOProduct.Columns.Add(colSubCon);

                    return(poList);
                }
                else
                {
                    MessageBox.Show("PO Id not found");
                }
            }
            else
            {
                MessageBox.Show("PO Id not found");
            }
            return(null);
        }
Esempio n. 9
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int id = 0;

            int.TryParse(tbId.Text, out id);
            if (id != 0)
            {
                Invoice currentInvoice = BLInvoice.GetInvoiceById(APCContext, id);
                if (currentInvoice != null)
                {
                    decimal paymentDue = 0;
                    if (decimal.TryParse(tbPaymentDue.Text, out paymentDue))
                    {
                        if (calDueDate.Value != null)
                        {
                            //if (ddlPO.SelectedValue != null)
                            //{
                            if (ddlProject.SelectedValue != null)
                            {
                                PO      selectedPO      = BLPO.GetPOById(APCContext, int.Parse(ddlPO.SelectedValue.ToString()));
                                Project selectedProject = BLProject.GetProjectById(APCContext, int.Parse(ddlProject.SelectedValue.ToString()));

                                currentInvoice.TotalDue   = paymentDue;
                                currentInvoice.DueDate    = calDueDate.Value;
                                currentInvoice.ScannedDoc = tbScannedDoc.Text;
                                currentInvoice.Project    = selectedProject;
                                APCContext.SaveChanges();

                                DeleteInvoicePO(currentInvoice);
                                InsertInvoicePO(currentInvoice);

                                deleteInvoice_Product(currentInvoice);
                                insertInvoice_Product(currentInvoice);

                                MessageBox.Show("Invoice Details Successfully Updated");
                                ClearContent();
                            }
                            else
                            {
                                MessageBox.Show("Please select the associated Project");
                            }
                            //}
                            //else
                            //    MessageBox.Show("Please select the associated PO Number");
                        }
                        else
                        {
                            MessageBox.Show("Please specify a correct due date");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please specify correct amount of Payment Due");
                    }
                }
                else
                {
                    MessageBox.Show("Invoice Id not found");
                }
            }
            else
            {
                MessageBox.Show("Invoice Id not found");
            }
        }
Esempio n. 10
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            decimal paymentDue = 0;

            if (decimal.TryParse(tbPaymentDue.Text, out paymentDue))
            {
                if (calDueDate.Value != null)
                {
                    if (ddlPO.SelectedValue != null)
                    {
                        if (BLSupplierInvoice.insertSupplierInvoice(APCContext, tbSupplierOriInvoiceNo.Text, paymentDue, calDueDate.Value, BLPO.GetPOById(APCContext, int.Parse(ddlPO.SelectedValue.ToString()))))
                        {
                            MessageBox.Show("SupplierInvoice Successfully Added");
                        }
                        else
                        {
                            MessageBox.Show("Please check your input");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please select the associated PO Number");
                    }
                }
                else
                {
                    MessageBox.Show("Please specify Due Date");
                }
            }
            else
            {
                MessageBox.Show("Please specify correct amount of Payment Due");
            }
        }