コード例 #1
0
ファイル: RequisitionFacade.cs プロジェクト: tianhang/SA39_AD
        public List<DisbursementDetails> getDisbursementDetails(string disbursementId)
        {
            List<DisbursementDetails> disbursementDetailsCollection = new List<DisbursementDetails>();

            try
            {
                var dsd = from d in ctx.disbursementDetails
                          join i in ctx.items
                          on d.itemId equals i.itemId
                          where d.disbursementId == disbursementId
                          select new
                          {
                              id = d.itemId,
                              des = i.description,
                              res = d.requestQty,
                              del = d.deliveredQty
                          };

                foreach (var d in dsd)
                {
                    DisbursementDetails disbursementDetails = new DisbursementDetails();
                    disbursementDetails.ItemId = d.id;
                    disbursementDetails.ItemName = d.des;
                    disbursementDetails.RequestedQty = Convert.ToInt32(d.res);
                    disbursementDetails.DeliveredQty = Convert.ToInt32(d.del);

                    disbursementDetailsCollection.Add(disbursementDetails);
                }
            }
            catch (Exception exception)
            {
                errorobj.WriteErrorLog("RequisitionFacade-getDisbursementDetails():::" + exception.ToString());
                disbursementDetailsCollection = null;
            }

            return disbursementDetailsCollection;
        }
コード例 #2
0
        public int loadController()
        {
            try
            {
                List<Disbursement> disbursementCollection = requisitionFacade.getDisbursementWithStatus("Outstanding");
                if(disbursementCollection.Count>0)
                {
                    return 0;
                }
                else
                {
                    List<Item> itemCollection = catalogueFacade.getItems("Active");
                    List<Department> departmentCollection = departmentFacade.getDepartments();
                    disbursementCollection.Clear();
                    disbursementCollection = new List<Disbursement>();

                    codeGenerator codeG = helperFacade.getCode("disbursementId");
                    Hashtable depItems = new Hashtable();
                    foreach(Department d in departmentCollection)
                    {
                        Disbursement disbursement = new Disbursement();
                        string newId = CodeGeneratorHelper.returnCode(codeG.prefix,codeG.lastValue);
                        codeG.lastValue = Convert.ToInt32(newId.Substring(codeG.prefix.Length));
                        disbursement.DisbursementId = newId;
                        disbursement.DepartmentId = d.DepartmentId;
                        disbursement.Date = DateTime.Now;
                        disbursement.Status = "Outstanding";
                        List<DisbursementDetails> disbursementDetailsCollection = new List<DisbursementDetails>();
                        disbursement.DisbursementDetailsCollection = disbursementDetailsCollection;
                        disbursementCollection.Add(disbursement);
                        depItems.Add(d.DepartmentId, 0);
                    }

                    foreach(Item item in itemCollection)
                    {
                        foreach (Department d in departmentCollection)
                        {
                            depItems[d.DepartmentId]= 0;
                        }
                        List<DisbursementHelper> disbursementHelperCollection = requisitionFacade.getRequisitionsForDisbursement(item.ItemId);
                        if (disbursementHelperCollection.Count > 0)
                        {
                            foreach (DisbursementHelper d in disbursementHelperCollection)
                            {
                                if (item.StockBalance > 0)
                                {
                                    if (item.StockBalance >= d.RequestedQty)
                                    {
                                        depItems[d.DepartmentId] = Convert.ToInt32(depItems[d.DepartmentId]) + d.RequestedQty;
                                        item.StockBalance -= d.RequestedQty;
                                    }
                                    else
                                    {
                                        depItems[d.DepartmentId] = Convert.ToInt32(depItems[d.DepartmentId]) + item.StockBalance;
                                        item.StockBalance -= item.StockBalance;
                                    }
                                    d.Status = "In Progress";
                                    requisitionFacade.updateRequisitionStatus(d.RequisitionId,"In Progress");
                                }
                                else
                                {
                                    break;
                                }
                            }

                            foreach (Department d in departmentCollection)
                            {
                                if (Convert.ToInt32(depItems[d.DepartmentId]) > 0)
                                {
                                    DisbursementDetails disbursementDetails = new DisbursementDetails();
                                    disbursementDetails.ItemId = item.ItemId;
                                    disbursementDetails.RequestedQty = Convert.ToInt32(depItems[d.DepartmentId]);
                                    Disbursement disbursement = disbursementCollection.Find(e => e.DepartmentId == d.DepartmentId);
                                    List<DisbursementDetails> disbursementDetailsCollection = disbursement.DisbursementDetailsCollection;
                                    disbursementDetailsCollection.Add(disbursementDetails);
                                    disbursement.DisbursementDetailsCollection = disbursementDetailsCollection;
                                }
                            }
                        }
                    }

                    foreach(Disbursement disbursement in disbursementCollection)
                    {
                        requisitionFacade.createDibursement(disbursement);
                    }

                    helperFacade.updateCode(codeG);

                    return 1;
                }

            }
            catch (Exception exception)
            {
                errorobj.WriteErrorLog("GenerateDisbursementController-loadController():::" + exception.ToString());
                return -1;
            }
        }
コード例 #3
0
        //lillte change for valide
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (ddlItem.SelectedIndex != 0 && ddlDepartment.SelectedIndex != 0 && ddlCategory.SelectedIndex != 0)
            {
                if (Page.IsValid)
                {
                    //lblNoti.Text = string.Empty;
                    lblRequisitionItemList.Visible = true;
                    lblRequisitionItemList.Text = "Disbursement Item List";
                    dgvRequisitionItemList.Visible = true;
                    List<DisbursementDetails> DBList = new List<DisbursementDetails>();
                    bool flag = false;
                    if (Session["DBList"] != null)
                    {
                        DBList = (List<DisbursementDetails>)Session["DBList"];
                        foreach (DisbursementDetails db in DBList)
                        {
                            if (db.ItemId == ddlItem.SelectedValue)
                            {
                                //lblmsg.Text = "Cannot add the same item twice.";
                                this.Message("Cannot add the same item twice.");
                                flag = true;
                                return;
                            }
                        }
                    }
                    if (!flag)
                    {
                        DisbursementDetails dd = new DisbursementDetails();
                        dd.ItemId = ddlItem.SelectedValue;
                        dd.ItemName = eDController.getItem(ddlItem.SelectedValue).description;
                        dd.RequestedQty = Convert.ToInt32(txtQuantity.Text);
                        dd.DeliveredQty = dd.RequestedQty;
                        DBList.Add(dd);
                        Session["DBList"] = DBList;
                    }
                    btnSubmit.Visible = true;

                    dgvRequisitionItemList.DataSource = DBList;
                    dgvRequisitionItemList.DataBind();

                }

                else
                {
                    string itemId = ddlItem.SelectedValue;
                    int bal = Convert.ToInt32(eDController.getItem(itemId).stockBalance);
                    string itemName = eDController.getItem(itemId).description;
                    string txtmessage = "The are only " + bal + " for item-" + itemName;
                    this.Message(txtmessage);
                }
            }
            else
            {
                //lblmsg.Text = "Please select one item and department.";
                this.Message("Please select one item and department.");
            }
        }