Esempio n. 1
0
        public void NotifyRequestDepartmentStockIn(long departmentId)
        {
            //ClientUtility.Log(logger, departmentId + " requesting stock-out information.");

            try
            {
                ObjectCriteria objectCriteria = new ObjectCriteria();
                objectCriteria.AddEqCriteria("OtherDepartmentId", departmentId);
                objectCriteria.AddEqCriteria("ConfirmFlg", (long)3);

                IList list = DepartmentStockOutLogic.FindAll(objectCriteria);
                Department destDept = new Department
                                          {
                                              DepartmentId = CurrentDepartment.Get().DepartmentId
                                          };
                if (list != null && list.Count > 0)
                {

                    ((MainForm)GlobalCache.Instance().MainForm).ServiceStatus.Text = " Gửi thông tin ...";
                    ClientUtility.Log(logger, " Co " + list.Count + " phieu tra hang ve " + departmentId);
                    IList stockInList = new ArrayList();
                    foreach (DepartmentStockOut departmentStockOut in list)
                    {
                        foreach (DepartmentStockOutDetail detail in departmentStockOut.DepartmentStockOutDetails)
                        {
                            string prdMasterId = detail.Product.ProductMaster.ProductMasterId;
                        }
                        FastDepartmentStockInMapper mapper = new FastDepartmentStockInMapper();
                        DepartmentStockIn stockIn = mapper.Convert(departmentStockOut);
                        /*stockInList.Add(stockIn);*/
                        serverService.InformDepartmentStockInSuccess(destDept,stockIn,departmentStockOut.DepartmentStockOutPK.DepartmentId);
                    }
                    /*object[] array = new object[stockInList.Count];
                    int i = 0;
                    foreach (DepartmentStockIn @out in stockInList)
                    {
                        array[i] = @out;
                        i++;
                    }
                    ClientUtility.Log(logger, departmentId + " da duoc gui thong tin tra hang.");
                    serverService.InformMultiDepartmentStockInSuccess(destDept, array, array.Length);*/
                }
            }
            catch (Exception exception)
            {
                ClientUtility.Log(logger, exception.Message);
            }
        }
Esempio n. 2
0
        public void MakeRawDepartmentStockOut(Department department, DepartmentStockOut stockOut, DepartmentPrice price)
        {
            DataAccessLayer dalSubStock = new DataAccessLayer(Properties.Settings.Default.SubStockDB);
            DataAccessLayer dalSalePoint = new DataAccessLayer(Properties.Settings.Default.SalePointDB);

            //DataAccessLayer dalSalePoint = new DataAccessLayer("achay");

            /*try
            {*/

            try
            {

                DepartmentStockIn stockIn = new FastDepartmentStockInMapper().Convert(stockOut);
                // get max stock in id
                string deptStr = "";
                string extraZero = "";
                string startNum = "";

                if(department.DepartmentId > 999)
                {
                    deptStr = department.DepartmentId.ToString();
                    extraZero = "000";
                    startNum = "001";
                }
                else
                {
                    deptStr = string.Format("{0:000}", department.DepartmentId);
                    extraZero = "00000";
                    startNum = "00001";
                }

                string dateStr = DateTime.Now.ToString("yyMMdd");
                var selectMaxIdSQL = " select max(stock_in_id) from department_stock_in where stock_in_id > '" + dateStr + deptStr + extraZero + "'";

                ServerUtility.Log(logger, selectMaxIdSQL);
                //var maxId = dalSalePoint.GetSingleValue(selectMaxIdSQL);
                var maxId = dalSalePoint.GetSingleValue(selectMaxIdSQL);
                string stockInId = "";
                if(maxId == null || maxId.ToString() == string.Empty)
                {
                    stockInId = dateStr + deptStr + startNum;
                }
                else
                {
                    stockInId = string.Format("{0:00000000000000}", (Int64.Parse(maxId.ToString()) + 1));
                }

                // search in department_stock_in_history
                string selectHistory = " select stock_in_id from department_stock_in_history "
                                       + " where SOURCE_DEPARTMENT_ID = " + stockOut.DepartmentStockOutPK.DepartmentId
                                       + " and stock_out_id = " + stockOut.DepartmentStockOutPK.StockOutId;
                ServerUtility.Log(logger, selectHistory);
                var existStockInId = dalSalePoint.GetSingleValue(selectHistory);
                if (existStockInId == null || existStockInId.ToString() == string.Empty)
                {
                    string insertHistory = " insert into department_stock_in_history(stock_out_id,source_department_id,stock_in_id,dest_department_id,description,create_id,create_date,update_id,update_date ) values( "
                                           + stockOut.DepartmentStockOutPK.StockOutId + ","
                                           + stockOut.DepartmentStockOutPK.DepartmentId + ",'"
                                           + stockInId + "',"
                                           + stockIn.DepartmentStockInPK.DepartmentId + ",'"
                                           + " Xuat hang xuong cua hang " + "',"
                                           + "'admin'" + ","
                                           + "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',"
                                           + "'admin'" + ","
                                           + "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
                    ServerUtility.Log(logger, insertHistory);
                    dalSalePoint.ExecuteQuery(insertHistory);
                }
                else
                {
                    InformMessage(stockOut.DepartmentStockOutPK.StockOutId,SUBTODEPT, true,
                    stockOut.DepartmentStockOutPK.StockOutId + " đã đến " + stockOut.OtherDepartmentId + " trước đó. Không thể truyền lại !");
                    return;
                }

                DoStockIn(dalSalePoint, department, stockIn, true);
                InformMessage(stockOut.DepartmentStockOutPK.StockOutId,SUBTODEPT, false,
                    stockOut.DepartmentStockOutPK.DepartmentId +  " đã truyền "+ stockOut.DepartmentStockOutPK.StockOutId +" xuống " + stockOut.OtherDepartmentId + " thành công !");
            }
            catch (Exception exception)
            {
                ServerUtility.Log(logger,exception.Message);
                ServerUtility.Log(logger, exception.StackTrace);
                InformMessage(stockOut.DepartmentStockOutPK.StockOutId,SUBTODEPT, true,
                    stockOut.DepartmentStockOutPK.DepartmentId + " đã truyền " + stockOut.DepartmentStockOutPK.StockOutId + " xuống " + stockOut.OtherDepartmentId + " thất bại !");
            }
        }
Esempio 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;
        }