void mainStockOutReportView_LoadStockOutsEvent(object sender, StockOutConfirmEventArgs e)
        {
            DateTime startTime = e.ReportDateStockOutParam.FromDate;
            DateTime endTime = e.ReportDateStockOutParam.ToDate;

            IList list = StockOutLogic.FindStockOut(startTime, endTime);
            if (list != null)
            {
                IList parentList = new ArrayList();
                for (int i = 0; i < list.Count; i++)
                {
                    IList childList = new ArrayList();
                    childList.Add(((IList)list[i])[0]);
                    childList.Add(((IList)list[i])[1]);
                    childList.Add(((IList)list[i])[2]);
                    long departmentId = (long)((IList)list[i])[2];
                    Department dep = DepartmentLogic.FindById(departmentId);
                    childList.Add(dep);
                    parentList.Add(childList);
                }
                e.ResultStockOutList = parentList;
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectedRows = dgvStockOut.SelectedRows;
            if (!(selectedRows.Count > 0))
            {
                return;
            }

            StockOutConfirmEventArgs eventArgs = new StockOutConfirmEventArgs();

            IList list = new ArrayList();
            foreach (DataGridViewRow row in selectedRows)
            {
                list.Add(deptStockOutList[row.Index].StockOut);
            }

            eventArgs.ConfirmDepartmentStockOutList = list;
            EventUtility.fireEvent(ConfirmStockOutEvent, this, eventArgs);
            if (!eventArgs.HasErrors)
            {

            }
            ClearForm();
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            deptStockOutList.Clear();
            StockOutConfirmEventArgs eventArgs = new StockOutConfirmEventArgs();
            eventArgs.ReportDateStockOutParam =
                new ReportDateStockOutParam
                {
                    FromDate = DateUtility.ZeroTime(dtpFrom.Value),
                    ToDate = DateUtility.MaxTime(dtpTo.Value)
                };
            EventUtility.fireEvent(LoadStockOutsEvent, this, eventArgs);

            if (eventArgs.ResultStockOutList != null)
            {
                foreach (IList result in eventArgs.ResultStockOutList)
                {
                    StockOutView stockOutView = new StockOutView();
                    stockOutView.StockOut = (StockOut)result[0];
                    stockOutView.TotalQuantity = (long)result[1];
                    stockOutView.Department = (Department)result[3];

                    if (stockOutView.Department != null)
                    {
                        stockOutView.DepartmentName = stockOutView.Department.DepartmentName;
                    }
                    else
                    {
                        stockOutView.DepartmentName = " Kho chính";
                    }
                    stockOutView.CreateDate = stockOutView.StockOut.CreateDate;
                    deptStockOutList.Add(stockOutView);
                }
            }
            else
            {
                MessageBox.Show(" Không có hoá đơn xuất kho nào cần xác nhận.");
            }

            bdsDeptStockOut.EndEdit();
            dgvStockOutDetail.Refresh();
            dgvStockOutDetail.Invalidate();
            //CreateCountOnList();
        }
 void mainStockOutReportView_DenyStockOutEvent(object sender, StockOutConfirmEventArgs e)
 {
     IList stockOutIds = e.DenyStockOutIdsList;
     foreach (var id in stockOutIds)
     {
         StockOut stockOut = StockOutLogic.FindById(id);
         stockOut.ConfirmFlg = 0;
         stockOut.DelFlg = 1;
         stockOut.NotUpdateMainStock = true;
         foreach (StockOutDetail inDetail in stockOut.StockOutDetails)
         {
             inDetail.DelFlg = 1;
         }
         StockOutLogic.Update(stockOut);
     }
 }
 void mainStockOutReportView_ConfirmStockOutEvent(object sender, StockOutConfirmEventArgs e)
 {
     IList stockOutIds = e.ConfirmStockOutIdsList;
     foreach (var id in stockOutIds)
     {
         StockOut stockOut = StockOutLogic.FindById(id);
         stockOut.ConfirmFlg = 0;
         StockOutLogic.Update(stockOut);
     }
 }
 void mainStockOutReportView_LoadEditStockOutsEvent(object sender, StockOutConfirmEventArgs e)
 {
     e.EditStockOut = StockOutLogic.FindById(e.StockOutId);
 }
        void mainStockOutReportView_LoadConfirmingStockOutsEvent(object sender, StockOutConfirmEventArgs e)
        {
            DateTime startTime = DateUtility.ZeroTime(e.ReportDateStockOutParam.FromDate);
            DateTime endTime = DateUtility.MaxTime(e.ReportDateStockOutParam.ToDate);
            ObjectCriteria objectCriteria = new ObjectCriteria();
            objectCriteria.AddEqCriteria("DelFlg", 0);
            objectCriteria.AddEqCriteria("ConfirmFlg", 1);
            objectCriteria.AddBetweenCriteria("StockOutDate", startTime, endTime);

            IList stockOutList = StockOutLogic.FindAll(objectCriteria);
            e.ResultStockOutList = stockOutList;
        }
 void mainStockOutReportView_GetPriceEvent(object sender, StockOutConfirmEventArgs e)
 {
 }
        private void button1_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection
            selectedRowCollection = dgvStockOut.SelectedRows;

            IList stockIds = new ArrayList();
            foreach (DataGridViewRow viewRow in selectedRowCollection)
            {
                long stockOutId = Int64.Parse(dgvStockOut[0, viewRow.Index].Value.ToString());
                stockIds.Add(stockOutId);
            }
            StockOutConfirmEventArgs eventArgs = new StockOutConfirmEventArgs();
            eventArgs.DenyStockOutIdsList = stockIds;
            EventUtility.fireEvent(DenyStockOutEvent, this, eventArgs);
            SearchStockOut();
            /*DataGridViewSelectedRowCollection selectedRows = dgvStockOut.SelectedRows;
            if(!(selectedRows.Count >0) )
            {
                return;
            }

            StockOutConfirmEventArgs eventArgs = new StockOutConfirmEventArgs();

            IList list = new ArrayList();
            foreach (DataGridViewRow row in selectedRows)
            {
                list.Add(deptStockOutList[row.Index].StockOut);
            }

            eventArgs.DenyStockInList = list;
            EventUtility.fireEvent(DenyStockOutEvent,this,eventArgs);
            if(!eventArgs.HasErrors)
            {

            }
            ClearForm();*/
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection
            selectedRowCollection = dgvStockOut.SelectedRows;

            IList stockIds = new ArrayList();
            foreach (DataGridViewRow viewRow in selectedRowCollection)
            {
                long stockOutId = Int64.Parse(dgvStockOut[0, viewRow.Index].Value.ToString());
                stockIds.Add(stockOutId);
            }
            StockOutConfirmEventArgs eventArgs = new StockOutConfirmEventArgs();
            eventArgs.ConfirmStockOutIdsList = stockIds;
            EventUtility.fireEvent(ConfirmStockOutEvent,this,eventArgs);
            SearchStockOut();
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if(dgvStockOut.CurrentCell == null)
               return;
            long stockOutId = Int64.Parse(dgvStockOut[0, dgvStockOut.CurrentCell.RowIndex].Value.ToString());

            StockOutConfirmEventArgs eventArgs = new StockOutConfirmEventArgs();
            eventArgs.StockOutId = stockOutId;

            EventUtility.fireEvent(LoadEditStockOutsEvent, this, eventArgs);

            if(eventArgs.EditStockOut != null)
            {
                DepartmentStockInFromMainEditForm form =
                    GlobalUtility.GetOnlyChildFormObject<DepartmentStockInFromMainEditForm>(GlobalCache.Instance().MainForm,
                                                                                            FormConstants.
                                                                                                DEPARTMENT_STOCK_IN_EXTRA_EDIT_FORM);
                form.StockOut = eventArgs.EditStockOut;
                form.Closed += new EventHandler(form_Closed);
                form.Show();
            }
        }