Exemple #1
0
 private void ProjectForm_Load(object sender, EventArgs e)
 {
     APCContext             = new APCEntities();
     cbClient.DataSource    = APCContext.Client;
     cbClient.DisplayMember = "Name";
     cbClient.ValueMember   = "Id";
 }
Exemple #2
0
        private void InvoiceForm_Load(object sender, EventArgs e)
        {
            APCContext = new APCEntities();

            List <Project> projectList = BLProject.GetAllProject(APCContext);

            ddlProject.DataSource    = projectList;
            ddlProject.DisplayMember = "Name";
            ddlProject.ValueMember   = "Id";

            dgInvoiceProduct.AutoGenerateColumns = false;
            dgInvoiceProduct.DataSource          = createInvoiceProductTable();
            //dgInvoiceProduct.Columns.Remove("Name");
            //dgInvoiceProduct.Columns.Remove("Kurs");
            //dgInvoiceProduct.Columns.Remove("SubCon");

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

            colName.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
            colName.DataSource   = APCContext.Category;

            DataGridViewComboBoxColumn colKurs = BLHelper.ReturnDataGridComboBoxColumn("Name", "Name", "Name", "Name");

            colName.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
            colKurs.DataSource   = APCContext.Kurs;

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

            //dgInvoiceProduct.Columns.Insert(0, colName);
            //dgInvoiceProduct.Columns.Insert(5, colKurs);
            dgInvoiceProduct.Columns.Add(colName);
            dgInvoiceProduct.Columns.Add(colKurs);
            dgInvoiceProduct.Columns.Add(colSubCon);
        }
Exemple #3
0
        private void Report_UsagePerProjectForm_Load(object sender, EventArgs e)
        {
            APCContext = new APCEntities();
            DataTable dt = ProjectArcon.DataLayer.Report.GetSummaryPerProject();

            dgProject.DataSource = GetTotalPerProject(dt);
        }
Exemple #4
0
 private void SupplierInvoiceForm_Load(object sender, EventArgs e)
 {
     APCContext          = new APCEntities();
     ddlPO.DataSource    = BLPO.GetAllPO(APCContext);
     ddlPO.DisplayMember = "Id";
     ddlPO.ValueMember   = "Id";
 }
Exemple #5
0
 public static Supplier GetSupplierById(APCEntities APCContext, int id)
 {
     if (APCContext.Supplier.Where("it.Id = @Id", new ObjectParameter("Id", id)).Count() > 0)
     {
         return(APCContext.Supplier.Where("it.Id = @Id", new ObjectParameter("Id", id)).First());
     }
     return(null);
 }
Exemple #6
0
 public static Project_Workers GetProject_WorkersById(APCEntities APCContext, int id)
 {
     if (APCContext.Project_Workers.Where("it.Id = @Id", new ObjectParameter("Id", id)).Count() > 0)
     {
         return(APCContext.Project_Workers.Where("it.Id = @Id", new ObjectParameter("Id", id)).First());
     }
     return(null);
 }
Exemple #7
0
 public static Client GetClientById(APCEntities APCContext, int id)
 {
     if (APCContext.Client.Where("it.Id = @Id", new ObjectParameter("Id", id)).Count() > 0)
     {
         return(APCContext.Client.Where("it.Id = @Id", new ObjectParameter("Id", id)).First());
     }
     return(null);
 }
Exemple #8
0
 public static Invoice_Product GetInvoice_ProductById(APCEntities APCContext, int id)
 {
     if (APCContext.Invoice_Product.Where("it.Id = @Id", new ObjectParameter("Id", id)).Count() > 0)
     {
         return(APCContext.Invoice_Product.Where("it.Id = @Id", new ObjectParameter("Id", id)).First());
     }
     return(null);
 }
Exemple #9
0
 public static Invoice_PO GetInvoicePOByPOId(APCEntities APCContext, int poId)
 {
     ObjectParameter[] listParameter = new ObjectParameter[1];
     listParameter[0] = new ObjectParameter("POId", poId);
     if (APCContext.Invoice_PO.Where("it.PO.Id= @POId", listParameter).Count() > 0)
         return APCContext.Invoice_PO.Where("it.PO.Id= @POId", listParameter).First();
     return null;
 }
Exemple #10
0
 public static List <Invoice_PO> GetListInvoicePOByInvoiceId(APCEntities APCContext, int id)
 {
     if (APCContext.Invoice_PO.Where("it.Invoice.Id = @Id", new ObjectParameter("Id", id)).Count() > 0)
     {
         return(APCContext.Invoice_PO.Where("it.Invoice.Id = @Id", new ObjectParameter("Id", id)).ToList());
     }
     return(null);
 }
Exemple #11
0
 public static List<Supplier> GetSupplierListById(APCEntities APCContext, int id)
 {
     if (APCContext.Supplier.AsEnumerable().Where(x => x.Id == id).Count() > 0)
     {
         return APCContext.Supplier.AsEnumerable().Where(x => x.Id == id).ToList();
     }
     else
         return null;
 }
Exemple #12
0
 public static List<Supplier> GetSupplierByName(APCEntities APCContext, string name)
 {
     if (APCContext.Supplier.AsEnumerable().Where(x => x.Name.Contains(name)).Count() > 0)
     {
         return APCContext.Supplier.AsEnumerable().Where(x => x.Name.Contains(name)).ToList();
     }
     else
         return null;
 }
 public static List<Project_Workers> GetProject_WorkersByProjectId(APCEntities APCContext, int id)
 {
     if (APCContext.Project_Workers.AsEnumerable().Where(x => x.Project.Id == id).Count() > 0)
     {
         return APCContext.Project_Workers.AsEnumerable().Where(x => x.Project.Id == id).ToList();
     }
     else
         return null;
 }
 public static List<Project_Workers> GetProject_WorkersByProjectName(APCEntities APCContext, string name)
 {
     if (APCContext.Project_Workers.AsEnumerable().Where(x => x.Project.Name.Contains(name)).Count() > 0)
     {
         return APCContext.Project_Workers.AsEnumerable().Where(x => x.Project.Name.Contains(name)).ToList();
     }
     else
         return null;
 }
 public static List<Invoice_Product> GetInvoice_ProductByInvoiceId(APCEntities APCContext, int InvoiceId)
 {
     if (APCContext.Invoice_Product.AsEnumerable().Where(x => x.Invoice.Id == InvoiceId).Count() > 0)
     {
         return APCContext.Invoice_Product.AsEnumerable().Where(x => x.Invoice.Id == InvoiceId).ToList();
     }
     else
         return null;
 }
 public static List<SupplierInvoice> GetSupplierInvoiceBySupplierOriNo(APCEntities APCContext, string supplierOriNo)
 {
     if (APCContext.SupplierInvoice.AsEnumerable().Where(x => x.SupplierOriNo.Contains(supplierOriNo)).Count() > 0)
     {
         return APCContext.SupplierInvoice.AsEnumerable().Where(x => x.SupplierOriNo.Contains(supplierOriNo)).ToList();
     }
     else
         return null;
 }
Exemple #17
0
 public static Kurs GetKursByExactName(APCEntities APCContext, string name)
 {
     if (APCContext.Kurs.AsEnumerable().Where(x => x.Name.Contains(name)).Count() > 0)
     {
         return APCContext.Kurs.AsEnumerable().Where(x => x.Name.Contains(name)).First();
     }
     else
         return null;
 }
Exemple #18
0
 public static List<PO_Product> GetPO_ProductListById(APCEntities APCContext, int id)
 {
     if (APCContext.PO_Product.AsEnumerable().Where(x => x.Id == id).Count() > 0)
     {
         return APCContext.PO_Product.AsEnumerable().Where(x => x.Id == id).ToList();
     }
     else
         return null;
 }
Exemple #19
0
 public static List<PO> GetUninvoicedPOByProjectId(APCEntities APCContext, int projectId)
 {
     if (APCContext.PO.AsEnumerable().Where(x => (x.Project.Id == projectId)).Count() > 0)
     {
         return APCContext.PO.AsEnumerable().Where(x => (x.Project.Id == projectId) && (x.Invoiced == false)).ToList();
     }
     else
         return null;
 }
Exemple #20
0
 public static List<Category> GetCategoryByName(APCEntities APCContext, string name)
 {
     if (APCContext.Category.AsEnumerable().Where(x => x.Name.Contains(name)).Count() > 0)
     {
         return APCContext.Category.AsEnumerable().Where(x => x.Name.Contains(name)).ToList();
     }
     else
         return null;
 }
Exemple #21
0
 public static List<Category> GetCategoryListById(APCEntities APCContext, int id)
 {
     if (APCContext.Category.AsEnumerable().Where(x => x.Id == id).Count() > 0)
     {
         return APCContext.Category.AsEnumerable().Where(x => x.Id == id).ToList();
     }
     else
         return null;
 }
Exemple #22
0
 public static List<Workers> GetWorkersListById(APCEntities APCContext, int id)
 {
     if (APCContext.Workers.AsEnumerable().Where(x => x.Id == id).Count() > 0)
     {
         return APCContext.Workers.AsEnumerable().Where(x => x.Id == id).ToList();
     }
     else
         return null;
 }
Exemple #23
0
 public static List<Invoice> GetInvoiceByDate(APCEntities APCContext, DateTime startDate, DateTime endDate, bool paid)
 {
     if (APCContext.Invoice.AsEnumerable().Where(x => (x.DueDate >= startDate) && (x.DueDate <= endDate) && (x.Paid == paid)).Count() > 0)
     {
         return APCContext.Invoice.AsEnumerable().Where(x => (x.DueDate >= startDate) && (x.DueDate <= endDate) && (x.Paid == paid)).ToList();
     }
     else
         return null;
 }
Exemple #24
0
 public static Invoice GetInvoiceListById(APCEntities APCContext, int id)
 {
     if (APCContext.Invoice.AsEnumerable().Where(x => x.Id == id).Count() > 0)
     {
         return APCContext.Invoice.AsEnumerable().Where(x => x.Id == id).First();
     }
     else
         return null;
 }
Exemple #25
0
 public static Invoice_PO GetInvoicePOByPOId(APCEntities APCContext, int poId)
 {
     ObjectParameter[] listParameter = new ObjectParameter[1];
     listParameter[0] = new ObjectParameter("POId", poId);
     if (APCContext.Invoice_PO.Where("it.PO.Id= @POId", listParameter).Count() > 0)
     {
         return(APCContext.Invoice_PO.Where("it.PO.Id= @POId", listParameter).First());
     }
     return(null);
 }
 public static bool insertPaymentToSupplier(APCEntities APCContext, SupplierInvoice supplierInvoice, decimal paymentAmount, DateTime paymentDate)
 {
     PaymentToSupplier paymentToSupplier = new PaymentToSupplier();
     paymentToSupplier.SupplierInvoice = supplierInvoice;
     paymentToSupplier.PaymentAmount = paymentAmount;
     paymentToSupplier.PaymentDate = paymentDate;
     APCContext.AddToPaymentToSupplier(paymentToSupplier);
     APCContext.SaveChanges();
     return true;
 }
Exemple #27
0
 public static PO insertPO(APCEntities APCContext, Supplier supplier, Project project)
 {
     PO po = new PO();
     po.Supplier = supplier;
     po.Project = project;
     po.DateCreated = DateTime.Today;
     po.Invoiced = false;
     APCContext.AddToPO(po);
     APCContext.SaveChanges();
     return po;
 }
 public static List <SupplierInvoice> GetSupplierInvoiceByDate(APCEntities APCContext, DateTime startDate, DateTime endDate, bool paid)
 {
     if (APCContext.SupplierInvoice.AsEnumerable().Where(x => (x.DueDate >= startDate) && (x.DueDate <= endDate) && (x.Paid == paid)).Count() > 0)
     {
         return(APCContext.SupplierInvoice.AsEnumerable().Where(x => (x.DueDate >= startDate) && (x.DueDate <= endDate) && (x.Paid == paid)).ToList());
     }
     else
     {
         return(null);
     }
 }
 public static List <SupplierInvoice> GetSupplierInvoiceBySupplierOriNo(APCEntities APCContext, string supplierOriNo)
 {
     if (APCContext.SupplierInvoice.AsEnumerable().Where(x => x.SupplierOriNo.Contains(supplierOriNo)).Count() > 0)
     {
         return(APCContext.SupplierInvoice.AsEnumerable().Where(x => x.SupplierOriNo.Contains(supplierOriNo)).ToList());
     }
     else
     {
         return(null);
     }
 }
Exemple #30
0
 public static List <PO_Product> GetPO_ProductByPOId(APCEntities APCContext, int POId)
 {
     if (APCContext.PO_Product.AsEnumerable().Where(x => x.PO.Id == POId).Count() > 0)
     {
         return(APCContext.PO_Product.AsEnumerable().Where(x => x.PO.Id == POId).ToList());
     }
     else
     {
         return(null);
     }
 }
Exemple #31
0
 public static Invoice GetInvoiceListById(APCEntities APCContext, int id)
 {
     if (APCContext.Invoice.AsEnumerable().Where(x => x.Id == id).Count() > 0)
     {
         return(APCContext.Invoice.AsEnumerable().Where(x => x.Id == id).First());
     }
     else
     {
         return(null);
     }
 }
Exemple #32
0
 public static List <PO> GetUninvoicedPOByProjectId(APCEntities APCContext, int projectId)
 {
     if (APCContext.PO.AsEnumerable().Where(x => (x.Project.Id == projectId)).Count() > 0)
     {
         return(APCContext.PO.AsEnumerable().Where(x => (x.Project.Id == projectId) && (x.Invoiced == false)).ToList());
     }
     else
     {
         return(null);
     }
 }
Exemple #33
0
 public static List <Workers> GetWorkersListById(APCEntities APCContext, int id)
 {
     if (APCContext.Workers.AsEnumerable().Where(x => x.Id == id).Count() > 0)
     {
         return(APCContext.Workers.AsEnumerable().Where(x => x.Id == id).ToList());
     }
     else
     {
         return(null);
     }
 }
Exemple #34
0
        public static bool insertPaymentToSupplier(APCEntities APCContext, SupplierInvoice supplierInvoice, decimal paymentAmount, DateTime paymentDate)
        {
            PaymentToSupplier paymentToSupplier = new PaymentToSupplier();

            paymentToSupplier.SupplierInvoice = supplierInvoice;
            paymentToSupplier.PaymentAmount   = paymentAmount;
            paymentToSupplier.PaymentDate     = paymentDate;
            APCContext.AddToPaymentToSupplier(paymentToSupplier);
            APCContext.SaveChanges();
            return(true);
        }
Exemple #35
0
 public static List <Client> GetClientListById(APCEntities APCContext, int id)
 {
     if (APCContext.Client.AsEnumerable().Where(x => x.Id == id).Count() > 0)
     {
         return(APCContext.Client.AsEnumerable().Where(x => x.Id == id).ToList());
     }
     else
     {
         return(null);
     }
 }
Exemple #36
0
 public static Category GetCategoryByExactName(APCEntities APCContext, string name)
 {
     if (APCContext.Category.AsEnumerable().Where(x => x.Name.Contains(name)).Count() > 0)
     {
         return(APCContext.Category.AsEnumerable().Where(x => x.Name.Contains(name)).First());
     }
     else
     {
         return(null);
     }
 }
Exemple #37
0
 public static List <Supplier> GetSupplierByName(APCEntities APCContext, string name)
 {
     if (APCContext.Supplier.AsEnumerable().Where(x => x.Name.Contains(name)).Count() > 0)
     {
         return(APCContext.Supplier.AsEnumerable().Where(x => x.Name.Contains(name)).ToList());
     }
     else
     {
         return(null);
     }
 }
Exemple #38
0
 public static List <Supplier> GetSupplierListById(APCEntities APCContext, int id)
 {
     if (APCContext.Supplier.AsEnumerable().Where(x => x.Id == id).Count() > 0)
     {
         return(APCContext.Supplier.AsEnumerable().Where(x => x.Id == id).ToList());
     }
     else
     {
         return(null);
     }
 }
Exemple #39
0
 public static List <Project_Workers> GetProject_WorkersByWorkerId(APCEntities APCContext, int id)
 {
     if (APCContext.Project_Workers.AsEnumerable().Where(x => x.Workers.Id == id).Count() > 0)
     {
         return(APCContext.Project_Workers.AsEnumerable().Where(x => x.Workers.Id == id).ToList());
     }
     else
     {
         return(null);
     }
 }
Exemple #40
0
 public static List <Project_Workers> GetProject_WorkersByWorkerName(APCEntities APCContext, string name)
 {
     if (APCContext.Project_Workers.AsEnumerable().Where(x => x.Workers.Name.Contains(name)).Count() > 0)
     {
         return(APCContext.Project_Workers.AsEnumerable().Where(x => x.Workers.Name.Contains(name)).ToList());
     }
     else
     {
         return(null);
     }
 }
Exemple #41
0
 public static List <Invoice_Product> GetInvoice_ProductByInvoiceId(APCEntities APCContext, int InvoiceId)
 {
     if (APCContext.Invoice_Product.AsEnumerable().Where(x => x.Invoice.Id == InvoiceId).Count() > 0)
     {
         return(APCContext.Invoice_Product.AsEnumerable().Where(x => x.Invoice.Id == InvoiceId).ToList());
     }
     else
     {
         return(null);
     }
 }
        public static PaymentFromClient insertPaymentFromClient(APCEntities APCContext, Invoice invoice, decimal paymentAmount, DateTime paymentDate)
        {
            PaymentFromClient paymentFromClient = new PaymentFromClient();
            paymentFromClient.Invoice = invoice;
            paymentFromClient.PaymentAmount = paymentAmount;
            paymentFromClient.PaymentDate = paymentDate;
            APCContext.AddToPaymentFromClient(paymentFromClient);
            APCContext.SaveChanges();

            return paymentFromClient;
        }
        public static PaymentFromClient insertPaymentFromClient(APCEntities APCContext, Invoice invoice, decimal paymentAmount, DateTime paymentDate)
        {
            PaymentFromClient paymentFromClient = new PaymentFromClient();

            paymentFromClient.Invoice       = invoice;
            paymentFromClient.PaymentAmount = paymentAmount;
            paymentFromClient.PaymentDate   = paymentDate;
            APCContext.AddToPaymentFromClient(paymentFromClient);
            APCContext.SaveChanges();

            return(paymentFromClient);
        }
Exemple #44
0
        public static PO insertPO(APCEntities APCContext, Supplier supplier, Project project)
        {
            PO po = new PO();

            po.Supplier    = supplier;
            po.Project     = project;
            po.DateCreated = DateTime.Today;
            po.Invoiced    = false;
            APCContext.AddToPO(po);
            APCContext.SaveChanges();
            return(po);
        }
Exemple #45
0
 public void setId(int invoiceId, APCEntities APCContext1)
 {
     APCContext = APCContext1;
     DataTable dtPaymentFromCustomer = BLInvoice.GetInvoiceById(invoiceId);
     if (dtPaymentFromCustomer.Rows.Count > 0)
     {
         DataRow invoiceRow = dtPaymentFromCustomer.Rows[0];
         //int invoiceId = int.Parse(invoiceRow["Id"].ToString());
         tbInvoiceId.Text = invoiceRow["Id"].ToString();
         tbPaymentDue.Text = ((decimal.Parse(invoiceRow["TotalDue"].ToString())) - TotalPaid(invoiceId)).ToString("N");
     }
 }
Exemple #46
0
        private void Project_WorkersForm_Load(object sender, EventArgs e)
        {
            APCContext = new APCEntities();

            ddlSearchWorkers.DataSource    = APCContext.Workers;
            ddlSearchWorkers.DisplayMember = "Name";
            ddlSearchWorkers.ValueMember   = "Id";

            ddlSearchProject.DataSource    = APCContext.Project;
            ddlSearchProject.DisplayMember = "Name";
            ddlSearchProject.ValueMember   = "Id";
        }
Exemple #47
0
 public static bool insertClient(APCEntities APCContext, string name)
 {
     if (name.Trim() != "")
     {
         Client client = new Client();
         client.Name = name;
         APCContext.AddToClient(client);
         APCContext.SaveChanges();
         return true;
     }
     else
         return false;
 }
 public static DataTable GetPaymentToSupplierListBySupplierInvoiceId(APCEntities APCContext, int supplierInvoiceId)
 {
     SqlConnection conn = new SqlConnection(connectionString);
     SqlCommand objSqlCommand = new SqlCommand("sp_PaymentToSupplier_GetPaymentToSupplierBySupplierInvoiceId", conn);
     objSqlCommand.CommandType = CommandType.StoredProcedure;
     objSqlCommand.Parameters.AddWithValue("@Id", supplierInvoiceId);
     conn.Open();
     DataTable dt = new DataTable();
     SqlDataAdapter da = new SqlDataAdapter(objSqlCommand);
     da.Fill(dt);
     conn.Close();
     return dt;
 }
Exemple #49
0
        private void Project_WorkersForm_Load(object sender, EventArgs e)
        {
            APCContext              = new APCEntities();
            ddlWorker.DataSource    = APCContext.Workers;
            ddlWorker.DisplayMember = "Name";
            ddlWorker.ValueMember   = "Id";

            ddlProject.DataSource    = APCContext.Project;
            ddlProject.DisplayMember = "Name";
            ddlProject.ValueMember   = "Id";

            showWorkerSalary();
        }
Exemple #50
0
 public static bool insertSupplier(APCEntities APCContext, string name)
 {
     if (name.Trim() != "")
     {
         Supplier supplier = new Supplier();
         supplier.Name = name;
         APCContext.AddToSupplier(supplier);
         APCContext.SaveChanges();
         return true;
     }
     else
         return false;
 }
Exemple #51
0
        private void PaymentToSupplierForm_Load(object sender, EventArgs e)
        {
            lblTodaysDate.Text            = DateTime.Today.ToShortDateString();
            lblPurchaseNotInvoiced.Text   = calculateBalance(false, false, false).ToString();
            lblArconInvoiceNotPaid.Text   = calculateBalance(true, false, false).ToString();
            lblPaymentDueForSupplier.Text = calculateBalance(false, false, true).ToString();
            APCContext         = new APCEntities();
            cbPaid.Enabled     = false;
            cbInvoiced.Enabled = false;
            cbALL.Checked      = true;
            DataTable dt = BLSupplierInvoice.GetSupplierInvoiceDueDatePOInvoicedAndPaid(DateTime.Today.AddDays(14), cbInvoiced.Checked, cbPaid.Checked, cbALL.Checked);

            dgReminderSupplierPayment.DataSource = dt;
        }
Exemple #52
0
 public static bool insertCategory(APCEntities APCContext, string name)
 {
     if (name.Trim() != "")
     {
         Category category = new Category();
         category.Name = name;
         //category.ServiceCharge = serviceCharge;
         APCContext.AddToCategory(category);
         APCContext.SaveChanges();
         return true;
     }
     else
         return false;
 }
Exemple #53
0
 public static bool insertWorkers(APCEntities APCContext, string name, decimal salary)
 {
     if (name.Trim() != "")
     {
         Workers workers = new Workers();
         workers.Name = name;
         workers.Salary = salary;
         APCContext.AddToWorkers(workers);
         APCContext.SaveChanges();
         return true;
     }
     else
         return false;
 }
Exemple #54
0
 public static bool insertProject(APCEntities APCContext, string name, Client client)
 {
     if (name.Trim() != "")
     {
         Project project = new Project();
         project.Name = name;
         project.Client = client;
         APCContext.AddToProject(project);
         APCContext.SaveChanges();
         return true;
     }
     else
         return false;
 }
Exemple #55
0
 public static bool insertPO_Product(APCEntities APCContext, PO po, Category category, string description, int quantity, decimal price, decimal serviceCharge, decimal totalPrice, bool subcon)
 {
     PO_Product po_product = new PO_Product();
     po_product.PO = po;
     po_product.Category = category;
     po_product.Description = description;
     po_product.Quantity = quantity;
     po_product.Price = price;
     po_product.ServiceCharge = serviceCharge;
     po_product.PriceTotal = totalPrice;
     po_product.SubCon = subcon;
     APCContext.AddToPO_Product(po_product);
     APCContext.SaveChanges();
     return true;
 }
Exemple #56
0
 public static decimal GetTotalPO_ProductByPOId(APCEntities APCContext, int POId)
 {
     if (APCContext.PO_Product.AsEnumerable().Where(x => x.PO.Id == POId).Count() > 0)
     {
         List<PO_Product> poProduct = APCContext.PO_Product.AsEnumerable().Where(x => x.PO.Id == POId).ToList();
         decimal total = 0;
         for (int i = 0; i < poProduct.Count; i++)
         {
             total = total + (decimal)poProduct[i].PriceTotal;
         }
         return total;
     }
     else
         return 0;
 }
 public static bool insertInvoice_Product(APCEntities APCContext, Invoice invoice, Category category, string description, int quantity, string unit, decimal price, Kurs kurs, decimal serviceCharge, decimal totalPrice, bool subcon)
 {
     Invoice_Product invoice_product = new Invoice_Product();
     invoice_product.Invoice = invoice;
     invoice_product.Category = category;
     invoice_product.Description = description;
     invoice_product.Quantity = quantity;
     invoice_product.Unit = unit;
     invoice_product.Price = price;
     invoice_product.Kurs = kurs;
     invoice_product.ServiceCharge = serviceCharge;
     invoice_product.PriceTotal = totalPrice;
     invoice_product.SubCon = subcon;
     APCContext.AddToInvoice_Product(invoice_product);
     APCContext.SaveChanges();
     return true;
 }
 public static Project_Workers GetProject_WorkersByProjectWorkerAndTime(APCEntities APCContext, int projectId, int workerId, DateTime startDate, DateTime endDate)
 {
     if (APCContext.Project_Workers.AsEnumerable().Count() > 0)
     {
         if (APCContext.Project_Workers.AsQueryable().Where(x => x.Project.Id == projectId
             && x.Workers.Id == workerId
             && x.StartDate == startDate
             && x.EndDate == endDate).Count() > 0)
         {
             return APCContext.Project_Workers.AsEnumerable().Where(x => x.Project.Id == projectId
                 && x.Workers.Id == workerId
                 && x.StartDate == startDate
                 && x.EndDate == endDate).First();
         }
         else
             return null;
     }
     else
         return null;
 }
 public static Project_Workers GetProject_WorkersById(APCEntities APCContext,int id)
 {
     if(APCContext.Project_Workers.Where("it.Id = @Id", new ObjectParameter("Id", id)).Count() > 0)
         return APCContext.Project_Workers.Where("it.Id = @Id", new ObjectParameter("Id", id)).First();
     return null;
 }
 public static List<Project_Workers> GetAllProject_Workers(APCEntities APCContext)
 {
     return APCContext.Project_Workers.ToList();
 }