/// <summary>
 /// Delete DepartmentStockInHistory from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(DepartmentStockInHistory data)
 {
     HibernateTemplate.Delete(data);
 }
 /// <summary>
 /// Add DepartmentStockInHistory to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public DepartmentStockInHistory Add(DepartmentStockInHistory data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
Ejemplo n.º 3
0
        public void NotifyNewMultiDepartmentStockOut(Department department, DepartmentStockOut[] list, DepartmentPrice price)
        {
            if (CurrentDepartment.Get().DepartmentId != department.DepartmentId)
            {
                return;
            }

            IsDoingStockOut = true;
            ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Đang nhận thông tin ...";

                ClientUtility.Log(logger, department.DepartmentId + " dang nhan hang.");
                foreach (DepartmentStockOut stockOut in list)
                {
                    try
                    {
                    DepartmentStockInHistoryPK departmentStockInHistoryPk = new DepartmentStockInHistoryPK
                    {
                        SourceDepartmentId = stockOut.DepartmentStockOutPK.DepartmentId,
                        DestDepartmentId = CurrentDepartment.Get().DepartmentId,
                        StockOutId = stockOut.DepartmentStockOutPK.StockOutId
                    };

                    ObjectCriteria deptHistCrit = new ObjectCriteria();
                    deptHistCrit.AddEqCriteria("DepartmentStockInHistoryPK.SourceDepartmentId", stockOut.DepartmentStockOutPK.DepartmentId);
                    deptHistCrit.AddEqCriteria("DepartmentStockInHistoryPK.StockOutId", stockOut.DepartmentStockOutPK.StockOutId);
                    deptHistCrit.AddEqCriteria("DepartmentStockInHistoryPK.DestDepartmentId", department.DepartmentId);

                    IList deptHistList = DepartmentStockInHistoryLogic.FindAll(deptHistCrit);
                    // if it has exist in history so don't need to continue
                    if (deptHistList != null && deptHistList.Count > 0)
                    {
                        continue;
                    }

                    DepartmentStockIn stockIn;
                    // convert from stock out to stock in
                    stockIn = new FastDepartmentStockInMapper().Convert(stockOut);
                    // call method to sync
                    LogicResult logicResult = DepartmentStockInLogic.SyncFromSubStock(stockIn);
                    if (logicResult.HasError)
                    {
                        if (logicResult.Messages != null)
                        {
                            foreach (string message in logicResult.Messages)
                            {
                                ClientUtility.Log(logger, message);
                            }
                        }
                        serverService.InformDepartmentStockOutFail(stockOut.DepartmentStockOutPK.DepartmentId,
                                                                      stockOut.OtherDepartmentId,
                                                                      stockOut.DepartmentStockOutPK.StockOutId);
                    }
                    else
                    {
                        ClientUtility.Log(logger,
                                          " Hoan tat va phan hoi ... " +
                                          stockOut.DepartmentStockOutPK.DepartmentId.ToString());

                        // add to stock in history for avoiding duplicate
                        departmentStockInHistoryPk.StockInId = stockIn.DepartmentStockInPK.StockInId;
                        DepartmentStockInHistory departmentStockInHistory = new DepartmentStockInHistory();
                        departmentStockInHistory.DepartmentStockInHistoryPK = departmentStockInHistoryPk;
                        departmentStockInHistory.Description = stockIn.ToString();
                        departmentStockInHistory.CreateDate = DateTime.Now;
                        departmentStockInHistory.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                        departmentStockInHistory.UpdateDate = DateTime.Now;
                        departmentStockInHistory.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        DepartmentStockInHistoryLogic.Add(departmentStockInHistory);

                        serverService.InformDepartmentStockOutSuccess(stockOut.DepartmentStockOutPK.DepartmentId,
                                                                      stockOut.OtherDepartmentId,
                                                                      stockOut.DepartmentStockOutPK.StockOutId);
                        ((MainForm) GlobalCache.Instance().MainForm).ServiceStatus.Text = " Hoàn tất ! ";
                        ClientUtility.Log(logger, " Hoan tat!");
                    }
                    }
                    catch (Exception exp)
                    {
                        ClientUtility.Log(logger, exp.Message);
                    }
                }
            IsDoingStockOut = false;
        }
 public void Delete(DepartmentStockInHistory data)
 {
     DepartmentStockInHistoryDAO.Delete(data);
 }
 public DepartmentStockInHistory Add(DepartmentStockInHistory data)
 {
     DepartmentStockInHistoryDAO.Add(data);
     return data;
 }
 public void Update(DepartmentStockInHistory data)
 {
     DepartmentStockInHistoryDAO.Update(data);
 }