public CreateDiscrepencyReportControl() { currentEmployee = Util.ValidateUser(Constants.EMPLOYEE_ROLE.STORE_CLERK); inventory = new InventoryEntities(); discrepancyBroker = new DiscrepancyBroker(inventory); itemBroker = new ItemBroker(inventory); item = new Item(); itemPriceBroker = new ItemPriceBroker(inventory); itemprice = new ItemPrice(); discrepancy = new Discrepancy(); discrepancy.Id = discrepancyBroker.GetDiscrepancyId(); discrepancy.CreatedDate = DateTime.Now; discrepancy.CreatedBy = Util.GetEmployee(new EmployeeBroker(inventory)); discrepancy.Status = Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW); // discrepancyDetailList = new System.Data.Objects.DataClasses.EntityCollection<DiscrepancyDetail>(); dataColumn = new DataColumn[] { new DataColumn(columnName[0]), new DataColumn(columnName[1]), new DataColumn(columnName[2]), new DataColumn(columnName[3]), new DataColumn(columnName[4]), new DataColumn(columnName[5]) }; }
public StockAdjustment(string id, Discrepancy disId, DateTime createdDate, Employee createdBy, int status) { this.Id = id; this.Discrepancy = disId; this.CreatedDate = createdDate; this.CreatedBy = createdBy; this.Status = status; }
public DiscrepancyDetail(int id, Discrepancy disId, Item itemId, int disType, int qty, string remark) { this.Id = id; this.Discrepancy = disId; this.Item = itemId; this.DiscrepancyType = disType; this.Qty = qty; this.Remarks = remark; }
/// <summary> /// Retrieve the Discrepancy and DiscrepancyDetail information from Department Table according to the department Parameter /// Return Discrepancy /// </summary> /// <param name="discrepancy"></param> /// <returns></returns> public Discrepancy GetDiscrepancy(Discrepancy discrepancy) { try { discrepancyObj = inventory.Discrepancies.Where(disObj => disObj.Id == discrepancy.Id).First(); } catch (Exception e) { discrepancyObj = null; } return discrepancyObj; }
/// <summary> /// Deprecated Method for adding a new object to the Discrepancies EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDiscrepancies(Discrepancy discrepancy) { base.AddObject("Discrepancies", discrepancy); }
/// <summary> /// Create a new Discrepancy object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="createdDate">Initial value of the CreatedDate property.</param> /// <param name="status">Initial value of the Status property.</param> public static Discrepancy CreateDiscrepancy(global::System.Int32 id, global::System.DateTime createdDate, global::System.Int32 status) { Discrepancy discrepancy = new Discrepancy(); discrepancy.Id = id; discrepancy.CreatedDate = createdDate; discrepancy.Status = status; return discrepancy; }
/// <summary> /// Show all discrepancy list which status is show /// Created By:Zin Mar Thwin /// Created Date:28-01-2012 /// Modified By: /// Modified Date: /// Modification Reason: /// Modified By: /// Modified Date: /// Modification Reason: /// </summary> /// <param name="itemDescription"></param> /// <returns>The return value of this method is resultItem.</returns> //public DataTable GetDiscrepancyList() //{ // dt = new DataTable(); // dt.Columns.AddRange(discrepancyListColumn); // List<Discrepancy> list = discrepancyBroker.GetAllDiscrepancy(); // foreach (Discrepancy temp in list) // { // DataRow dr; // // requisitionDetail = new RequisitionDetail(); // if (temp.Status == Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW)) // { // // RequisitionDetail resultRequisitionDetail = requisitionBroker.GetRequisitionDetail(requisitionDetail); // dr = dt.NewRow(); // dr["id"] = temp.Id; // dr["createdBy"] = temp.CreatedBy.Name; // dr["createdDate"] = temp.CreatedDate; // int totalQty = 0; // foreach (DiscrepancyDetail tempDetail in temp.DiscrepancyDetails.ToList()) // { // totalQty += tempDetail.Qty; // } // dr["totalQty"] = totalQty; // dr["status"] = temp.Status; // dt.Rows.Add(dr); // } // } //List<Discrepancy> newList = new List<Discrepancy>(); //foreach (Discrepancy discrepancy in list) //{ // if (discrepancy.Status == Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW)) // newList.Add(discrepancy); //} //return dt; //} /// <summary> /// Show all discrepancies /// Created By:JinChengCheng /// Created Date:26-01-2012 /// Modified By: /// Modified Date: /// Modification Reason: /// Modified By: /// Modified Date: /// Modification Reason: /// </summary> /// <param name=""></param> /// <returns>The return type of this method is datatable.</returns> //public DataTable GetDiscrepancyList() //{ // DataTable dt = new DataTable(); // DataRow dr = new DataRow(); // discrepancyList = new List<Discrepancy>(); // List<Discrepancy> newDiscrepancyDetailList = new List<Discrepancy>(); // discrepancyList = discrepancyBroker.GetAllDiscrepancy(); // foreach (Discrepancy temp in discrepancyList) // { // if (discrepancy.status == (int)Constants.VISIBILITY_STATUS.SHOW) // newDiscrepancyDetailList.Add(discrepancy); // dt.NewRow(); // dr["voucherNo"] = null; // dr["createdBy"] = temp.Employee.Name; // dr["createdDate"] = temp.createddate; // int totalQty; // //List<DiscrepancyDetail> list = (List<DiscrepancyDetail>)temp.DiscrepancyDetails; // foreach (DiscrepancyDetail tempDetail in temp.DiscrepancyDetails.list) // { // totalQty+=tempDetail.Qty; // } // dr["totalQty"] = totalQty; // dr["status"] = temp.status; // dt.Rows.Add(dt); // } //} //public Discrepancy SelectDiscrepancy(int discrepancyId) //{ // Discrepancy discrepancy = new Discrepancy(); // discrepancy.id = discrepancyId; // return discrepancyBroker.GetDiscrepancy(discrepancy); //} /// <summary> /// Show one discrepancy detail according the discrepancyId selected /// Created By:JinChengCheng /// Created Date:26-01-2012 /// Modified By: /// Modified Date: /// Modification Reason: /// Modified By: /// Modified Date: /// Modification Reason: /// </summary> /// <param name="discrepancyId"></param> ///// <returns>The return type of this method is datatable.</returns> public DataTable SelectDiscrepancy(int discrepancyId) { if (dtt == null) { dtt = new DataTable(); dtt.Columns.AddRange(detailColumn); } else { dtt.Rows.Clear(); } discrepancy = new Discrepancy(); discrepancy.Id = discrepancyId; discrepancy = discrepancyBroker.GetDiscrepancy(discrepancy); //List<DiscrepancyDetail> discrepancyDetailList = (List<DiscrepancyDetail>)discrepancy.DiscrepancyDetails; //List<DiscrepancyDetail> supervisorDetails = new List<DiscrepancyDetail>(); //List<DiscrepancyDetail> managerDetails = new List<DiscrepancyDetail>(); //foreach (DiscrepancyDetail dd in discrepancy.DiscrepancyDetails) //{ // if (dd.DiscrepancyType == Converter.objToInt(Constants.DISCREPANCY_TYPE.SUPERVISOR)) // { // supervisorDetails.Add(dd); // } // else // { // managerDetails.Add(dd); // } //} //List<DiscrepancyDetail> currentList; //if (currentEmployee.Role.Id == Converter.objToInt(Constants.EMPLOYEE_ROLE.STORE_SUPERVISOR)) //{ // currentList = supervisorDetails; //} //else //{ // currentList = managerDetails; //} foreach (DiscrepancyDetail temp in GetList(discrepancy.DiscrepancyDetails.ToList())) { drr = dtt.NewRow(); drr[detailColumnName[0]] = temp.Item.Id; drr[detailColumnName[1]] = temp.Item.Description; drr[detailColumnName[2]] = temp.Qty; drr[detailColumnName[3]] = temp.Qty * 10;//temp.Item.Cost; drr[detailColumnName[4]] = temp.Remarks; dtt.Rows.Add(drr); } return dtt; }
/// <summary> /// Insert Discrepancy data to the Discrepancy and Discrepancy Detail Table according to the newdiscrepancy Parameter /// Return Constants.DB_STATUS /// </summary> /// <param name="newdiscrepancy"></param> /// <returns></returns> public Constants.DB_STATUS Insert(Discrepancy newdiscrepancy) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { inventory.AddToDiscrepancies(newdiscrepancy); inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return status; }
/// <summary> /// Logically delete the Discrepancy table by setting the status to 2 in the Discrepancy table /// Return Constants.DB_STATUS /// </summary> /// <param name="discrepancy"></param> /// <returns></returns> public Constants.DB_STATUS Delete(Discrepancy discrepancy) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { discrepancyObj = inventory.Discrepancies.Where(disObj => disObj.Id == discrepancy.Id).First(); discrepancyObj.Status = 2; foreach (DiscrepancyDetail discrepancyDetail in discrepancy.DiscrepancyDetails) { this.Delete(discrepancyDetail); } inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return status; }
/// <summary> /// Update Discrepancy data to the Discrepancy and Discrepancy Detail Table according to the discrepancy Parameter /// Return Constans.DB_STATUS /// </summary> /// <param name="discrepancy"></param> /// <returns></returns> public Constants.DB_STATUS Update(Discrepancy discrepancy) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { discrepancyObj = inventory.Discrepancies.Where(d => d.Id == discrepancy.Id).First(); Employee createdBy = inventory.Employees.Where(e => e.Id == discrepancy.CreatedBy.Id).First(); discrepancyObj.Id = discrepancy.Id; discrepancyObj.CreatedDate = discrepancy.CreatedDate; discrepancyObj.CreatedBy = createdBy; foreach (DiscrepancyDetail discrepancyDetail in discrepancy.DiscrepancyDetails) { this.Update(discrepancyDetail); } inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return status; }