Пример #1
0
        protected override void GetReceiptNotes(Resolver resolver)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(PickList));

            criteria.Add(Expression.Eq("IsPrinted", false));
            OrderHelper.SetOpenOrderStatusCriteria(criteria, "Status");                            //订单状态
            SecurityHelper.SetRegionSearchCriteria(criteria, "PartyFrom.Code", resolver.UserCode); //区域权限

            IList <PickList> pickList = criteriaMgr.FindAll <PickList>(criteria, 0, 5);

            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();

            if (pickList != null && pickList.Count > 0)
            {
                foreach (PickList pl in pickList)
                {
                    string newUrl = reportMgr.WriteToFile("PickList.xls", pl.PickListNo);
                    pl.IsPrinted = true;//to be refactored
                    pickListMgr.UpdatePickList(pl);
                    ReceiptNote receiptNote = PickList2ReceiptNote(pl);
                    receiptNote.PrintUrl = newUrl;
                    receiptNotes.Add(receiptNote);
                }
            }
            resolver.ReceiptNotes = receiptNotes;
        }
Пример #2
0
        private void PrintPickList(Resolver resolver, string[] region)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(PickList));

            criteria.Add(Expression.Eq("IsPrinted", false));
            criteria.Add(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT));
            criteria.Add(Expression.In("PartyFrom.Code", region));

            IList <PickList> pickList = criteriaMgr.FindAll <PickList>(criteria);

            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();

            if (pickList != null && pickList.Count > 0)
            {
                foreach (PickList pl in pickList)
                {
                    string newUrl = reportMgr.WriteToFile("PickList.xls", pl.PickListNo);
                    pl.IsPrinted = true;//to be refactored
                    pickListMgr.UpdatePickList(pl);
                    ReceiptNote receiptNote = PickList2ReceiptNote(pl);
                    receiptNote.PrintUrl = newUrl;
                    receiptNotes.Add(receiptNote);
                }
            }

            if (resolver.ReceiptNotes == null)
            {
                resolver.ReceiptNotes = receiptNotes;
            }
            else
            {
                IListHelper.AddRange <ReceiptNote>(resolver.ReceiptNotes, receiptNotes);
            }
        }
Пример #3
0
        private List <ReceiptNote> ConvertReceipsToReceiptNotes(IList <Receipt> Receipts)
        {
            if (Receipts == null)
            {
                return(null);
            }
            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();
            int seq = 1;

            foreach (Receipt receipt in Receipts)
            {
                ReceiptNote receiptNote = new ReceiptNote();
                receiptNote.CreateDate = receipt.CreateDate;
                receiptNote.CreateUser = receipt.CreateUser == null ? string.Empty : receipt.CreateUser.Name;
                receiptNote.Dock       = receipt.DockDescription;
                receiptNote.IpNo       = receipt.ReferenceIpNo;
                receiptNote.PartyFrom  = receipt.PartyFrom == null ? string.Empty : receipt.PartyFrom.Name;
                receiptNote.PartyTo    = receipt.PartyTo == null ? string.Empty : receipt.PartyTo.Name;
                receiptNote.ReceiptNo  = receipt.ReceiptNo;
                receiptNote.Sequence   = seq;
                receiptNotes.Add(receiptNote);
                seq++;
            }
            return(receiptNotes);
        }
Пример #4
0
        private void PrintInspect(Resolver resolver, string[] region)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(InspectOrder));

            criteria.Add(Expression.Eq("IsPrinted", false));
            criteria.Add(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE));
            criteria.Add(Expression.In("Region", region));

            IList <InspectOrder> inspectOrderList = criteriaMgr.FindAll <InspectOrder>(criteria);

            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();

            if (inspectOrderList != null && inspectOrderList.Count > 0)
            {
                foreach (InspectOrder inspectOrder in inspectOrderList)
                {
                    string newUrl = reportMgr.WriteToFile("InspectOrder.xls", inspectOrder.InspectNo);
                    inspectOrder.IsPrinted = true;//to be refactored
                    inspectOrderMgr.UpdateInspectOrder(inspectOrder);
                    ReceiptNote receiptNote = InspectOrder2ReceiptNote(inspectOrder);
                    receiptNote.PrintUrl = newUrl;
                    receiptNotes.Add(receiptNote);
                }
            }

            if (resolver.ReceiptNotes == null)
            {
                resolver.ReceiptNotes = receiptNotes;
            }
            else
            {
                IListHelper.AddRange <ReceiptNote>(resolver.ReceiptNotes, receiptNotes);
            }
        }
Пример #5
0
        private List <ReceiptNote> ConvertHusToReceiptNotes(IList <Hu> HuList)
        {
            if (HuList == null)
            {
                return(null);
            }
            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();
            int seq = 1;

            foreach (Hu hu in HuList)
            {
                ReceiptNote receiptNote = new ReceiptNote();
                receiptNote.CreateDate      = hu.CreateDate;
                receiptNote.CreateUser      = hu.CreateUser == null ? string.Empty : hu.CreateUser.Name;
                receiptNote.OrderNo         = hu.OrderNo;
                receiptNote.HuId            = hu.HuId;
                receiptNote.ItemDescription = hu.Item.Description;
                receiptNote.UnitCount       = hu.UnitCount;
                receiptNote.Qty             = hu.Qty;
                receiptNote.Sequence        = seq;
                receiptNote.ReceiptNo       = hu.ReceiptNo;
                receiptNotes.Add(receiptNote);
                seq++;
            }
            return(receiptNotes);
        }
Пример #6
0
        private ReceiptNote Repack2ReceiptNote(Repack repack)
        {
            ReceiptNote receiptNote = new ReceiptNote();

            receiptNote.OrderNo    = repack.RepackNo;
            receiptNote.CreateDate = repack.CreateDate;
            receiptNote.CreateUser = repack.CreateUser == null ? string.Empty : repack.CreateUser.Code;

            return(receiptNote);
        }
Пример #7
0
        private ReceiptNote InProcessLocation2ReceiptNote(InProcessLocation inProcessLocation)
        {
            ReceiptNote receiptNote = new ReceiptNote();

            receiptNote.OrderNo    = inProcessLocation.IpNo;
            receiptNote.CreateDate = inProcessLocation.CreateDate;
            receiptNote.CreateUser = inProcessLocation.CreateUser == null ? string.Empty : inProcessLocation.CreateUser.Code;
            receiptNote.Status     = inProcessLocation.Status;

            return(receiptNote);
        }
Пример #8
0
        private void BntAdd_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ErrorDetailsItem.Count != 0)
                {
                    MessageBox.Show("Something is not correct. Please check all your input again!");
                    return;
                }

                if (CurrentReceipt.ReceiptNoteDetails.Count == 0)
                {
                    MessageBox.Show("You have to choose the ingredient you want to input before add");
                    return;
                }

                // check if the Receipt Note have input Other Perchagse, must require the Note
                foreach (var details in CurrentReceipt.ReceiptNoteDetails.ToList())
                {
                    if (details.IgdId.Equals(ORTHER_PERCHAGSE_ID) && string.IsNullOrEmpty(details.Note))
                    {
                        MessageBox.Show(
                            "You have inputed the \"Orther Purchase\" in your Receipt. Please input the detail description in note before save data!");
                        return;
                    }
                }

                CurrentReceipt.Inday = DateTime.Now;
                _unitofwork.ReceiptNoteRepository.Insert(CurrentReceipt);

                //ToDo: Update the contain value in Warehouse database
                UpdateWareHouseContain();

                _unitofwork.Save();


                ReceiptDetailsList        = new List <ReceiptNoteDetail>();
                lvDataReceipt.ItemsSource = ReceiptDetailsList;
                lvDataReceipt.Items.Refresh();

                CurrentReceipt = new ReceiptNote()
                {
                    EmpId = (App.Current.Properties["EmpLogin"] as Employee).EmpId,
                    ReceiptNoteDetails = ReceiptDetailsList
                };


                LoadReceiptData();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong when trying to input the new Receipt! May be you should reload this app or call for support!");
            }
        }
Пример #9
0
        private ReceiptNote Receipt2ReceiptNote(Receipt receipt)
        {
            ReceiptNote receiptNote = new ReceiptNote();

            receiptNote.OrderNo    = receipt.ReceiptNo;
            receiptNote.CreateDate = receipt.CreateDate;
            receiptNote.CreateUser = receipt.CreateUser == null ? string.Empty : receipt.CreateUser.Code;
            receiptNote.Status     = "Close";

            return(receiptNote);
        }
Пример #10
0
        private ReceiptNote Order2ReceiptNote(OrderHead orderHead)
        {
            ReceiptNote receiptNote = new ReceiptNote();

            receiptNote.OrderNo    = orderHead.OrderNo;
            receiptNote.CreateDate = orderHead.CreateDate;
            receiptNote.CreateUser = orderHead.CreateUser == null ? string.Empty : orderHead.CreateUser.Code;
            receiptNote.Status     = orderHead.Status;

            return(receiptNote);
        }
Пример #11
0
        private ReceiptNote PickList2ReceiptNote(PickList pickList)
        {
            ReceiptNote receiptNote = new ReceiptNote();

            receiptNote.OrderNo    = pickList.PickListNo;
            receiptNote.CreateDate = pickList.CreateDate;
            receiptNote.CreateUser = pickList.CreateUser == null ? string.Empty : pickList.CreateUser.Code;
            receiptNote.Status     = pickList.Status;

            return(receiptNote);
        }
Пример #12
0
        private ReceiptNote InspectOrder2ReceiptNote(InspectOrder inspectOrder)
        {
            ReceiptNote receiptNote = new ReceiptNote();

            receiptNote.OrderNo    = inspectOrder.InspectNo;
            receiptNote.CreateDate = inspectOrder.CreateDate;
            receiptNote.CreateUser = inspectOrder.CreateUser == null ? string.Empty : inspectOrder.CreateUser.Code;
            receiptNote.Status     = inspectOrder.Status;

            return(receiptNote);
        }
Пример #13
0
        public ReceiptNoteEntity Update(EmployeeEntity EmployeeEntity, Guid ReceiptNoteId, ReceiptNoteEntity ReceiptNoteEntity)
        {
            if (ReceiptNoteEntity == null)
            {
                throw new NotFoundException();
            }
            ReceiptNoteEntity.Id = ReceiptNoteId;
            ReceiptNote ReceiptNote = new ReceiptNote(ReceiptNoteEntity);

            UnitOfWork.Complete();
            return(Get(EmployeeEntity, ReceiptNote.Id));
        }
Пример #14
0
        private void lvReceptNote_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ReceiptNote rn = lvReceptNote.SelectedItem as ReceiptNote;

            if (rn != null)
            {
                lvReceiptNoteDetail.ItemsSource = _unitofwork.ReceiptNoteDsetailsRepository.Get(c => c.RnId.Equals(rn.RnId));
            }
            else
            {
                lvReceiptNoteDetail.ItemsSource = new List <ReceiptNoteDetail>();
            }
        }
Пример #15
0
        public ReceiptNoteEntity Create(EmployeeEntity EmployeeEntity, ReceiptNoteEntity ReceiptNoteEntity)
        {
            if (ReceiptNoteEntity == null)
            {
                throw new NotFoundException();
            }

            ReceiptNote ReceiptNote = new ReceiptNote(ReceiptNoteEntity);

            UnitOfWork.ReceiptNoteRepository.AddOrUpdate(ReceiptNote);
            UnitOfWork.Complete();
            return(Get(EmployeeEntity, ReceiptNote.Id));
        }
Пример #16
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var lists = gridControl1.DataSource as List <ReceiptNoteDetail>;

            if (lists.Count() > 0)
            {
                var note = new ReceiptNote();
                note.SupplierId = (int)cbxSupplier.EditValue;
                note.StockId    = (int)cbxStock.EditValue;
                note.StaffId    = (int)cbxStaff.EditValue;
                note.Date       = (DateTime)txtDate.EditValue;
            }
        }
Пример #17
0
        public InputReceiptNote(AdminwsOfCloudPOS unitofwork, List <Ingredient> ingdList)
        {
            _unitofwork = unitofwork;
            InitializeComponent();

            this.IngdList = ingdList;
            lvDataIngredient.ItemsSource = IngdList;

            ReceiptDetailsList = new List <ReceiptNoteDetail>();
            CurrentReceipt     = new ReceiptNote()
            {
                EmpId = (App.Current.Properties["EmpLogin"] as Employee).EmpId,
                ReceiptNoteDetails = ReceiptDetailsList
            };
            lvDataReceipt.ItemsSource = ReceiptDetailsList;

            LoadReceiptData();
        }
Пример #18
0
        private void CreateRepack(Resolver resolver)
        {
            string[]           huIdArr      = resolver.Input.Split(',');
            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();

            foreach (string huId in huIdArr)
            {
                try
                {
                    IList <RepackDetail> repackDetailList  = new List <RepackDetail>();
                    LocationLotDetail    locationLotDetail = locationLotDetailMgr.CheckLoadHuLocationLotDetail(huId);
                    RepackDetail         inRepackDetail    = new RepackDetail();
                    inRepackDetail.LocationLotDetail = locationLotDetail;
                    inRepackDetail.Hu     = locationLotDetail.Hu;
                    inRepackDetail.IOType = BusinessConstants.IO_TYPE_IN;
                    inRepackDetail.Qty    = inRepackDetail.Hu.Qty * inRepackDetail.Hu.UnitQty;
                    repackDetailList.Add(inRepackDetail);

                    RepackDetail outRepackDetail = new RepackDetail();
                    outRepackDetail.itemCode = inRepackDetail.Hu.Item.Code;
                    outRepackDetail.IOType   = BusinessConstants.IO_TYPE_OUT;
                    outRepackDetail.Qty      = inRepackDetail.Qty;
                    repackDetailList.Add(outRepackDetail);

                    Repack repack = repackMgr.CreateDevanning(repackDetailList, userMgr.CheckAndLoadUser(resolver.UserCode));

                    ReceiptNote receiptNote = Repack2ReceiptNote(repack);
                    receiptNotes.Add(receiptNote);
                }

                catch (Exception ex)
                {
                    continue;
                }
            }
            if (resolver.ReceiptNotes == null)
            {
                resolver.ReceiptNotes = receiptNotes;
            }
            else
            {
                IListHelper.AddRange <ReceiptNote>(resolver.ReceiptNotes, receiptNotes);
            }
        }
Пример #19
0
        private void PrintASN(Resolver resolver, string[] region)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(InProcessLocation));

            criteria.Add(Expression.Eq("IsPrinted", false));
            criteria.Add(Expression.Eq("NeedPrintAsn", true));
            criteria.Add(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE));
            criteria.Add(Expression.Or(Expression.Eq("OrderType", BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION),
                                       Expression.Eq("OrderType", BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)));
            criteria.Add(Expression.In("PartyFrom.Code", region));

            IList <InProcessLocation> inProcessLocationList = criteriaMgr.FindAll <InProcessLocation>(criteria);

            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();

            if (inProcessLocationList != null && inProcessLocationList.Count > 0)
            {
                foreach (InProcessLocation inProcessLocation in inProcessLocationList)
                {
                    IList <object> list = new List <object>();
                    list.Add(inProcessLocation);
                    list.Add(inProcessLocation.InProcessLocationDetails);

                    string newUrl = reportMgr.WriteToFile(inProcessLocation.AsnTemplate, list);
                    inProcessLocation.IsPrinted = true;//to be refactored
                    inProcessLocationMgr.UpdateInProcessLocation(inProcessLocation);
                    ReceiptNote receiptNote = InProcessLocation2ReceiptNote(inProcessLocation);
                    receiptNote.PrintUrl = newUrl;
                    receiptNotes.Add(receiptNote);
                }
            }

            if (resolver.ReceiptNotes == null)
            {
                resolver.ReceiptNotes = receiptNotes;
            }
            else
            {
                IListHelper.AddRange <ReceiptNote>(resolver.ReceiptNotes, receiptNotes);
            }
        }
Пример #20
0
        private void PrintOrder(Resolver resolver, string[] region)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(OrderHead));

            criteria.Add(Expression.Eq("IsPrinted", false));
            criteria.Add(Expression.Eq("NeedPrintOrder", true));
            criteria.Add(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS));
            criteria.Add(Expression.In("Type", new string[] { BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER, BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT }));
            criteria.Add(Expression.In("PartyFrom.Code", region));

            IList <OrderHead> orderList = criteriaMgr.FindAll <OrderHead>(criteria);

            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();

            if (orderList != null && orderList.Count > 0)
            {
                foreach (OrderHead orderHead in orderList)
                {
                    IList <object> list = new List <object>();
                    list.Add(orderHead);
                    list.Add(orderHead.OrderDetails);

                    string newUrl = reportMgr.WriteToFile(orderHead.OrderTemplate, list);
                    orderHead.IsPrinted = true;//to be refactored
                    orderHeadMgr.UpdateOrderHead(orderHead);
                    ReceiptNote receiptNote = Order2ReceiptNote(orderHead);
                    receiptNote.PrintUrl = newUrl;
                    receiptNotes.Add(receiptNote);
                }
            }

            if (resolver.ReceiptNotes == null)
            {
                resolver.ReceiptNotes = receiptNotes;
            }
            else
            {
                IListHelper.AddRange <ReceiptNote>(resolver.ReceiptNotes, receiptNotes);
            }
        }
Пример #21
0
 public ReceiptNoteEntity(ReceiptNote ReceiptNote, params object[] args) : base(ReceiptNote)
 {
     foreach (object arg in args)
     {
         if (arg is Employee Employee)
         {
             EmployeeEntity = new EmployeeEntity(Employee);
         }
         if (arg is Supplier Supplier)
         {
             SupplierEntity = new SupplierEntity(Supplier);
         }
         if (arg is WareHouse WareHouse)
         {
             WareHouseEntity = new WareHouseEntity(WareHouse);
         }
         if (arg is ICollection <ReceiptNoteLine> ReceiptNoteLines)
         {
             ReceiptNoteLineEntities = ReceiptNoteLines.Select(model => new ReceiptNoteLineEntity(model, model.Product)).ToList();
         }
     }
 }
Пример #22
0
        private void PrintReceipt(Resolver resolver, string[] region)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(Receipt));

            criteria.Add(Expression.Eq("IsPrinted", false));
            criteria.Add(Expression.Eq("NeedPrint", true));
            criteria.Add(Expression.In("PartyTo.Code", region));

            IList <Receipt> receiptList = criteriaMgr.FindAll <Receipt>(criteria);

            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();

            if (receiptList != null && receiptList.Count > 0)
            {
                foreach (Receipt receipt in receiptList)
                {
                    IList <object> list = new List <object>();
                    list.Add(receipt);
                    list.Add(receiptDetailMgr.SummarizeReceiptDetails(receipt.ReceiptDetails));

                    string newUrl = reportMgr.WriteToFile(receipt.ReceiptTemplate, list);
                    receipt.IsPrinted = true;//to be refactored
                    receiptMgr.UpdateReceipt(receipt);
                    ReceiptNote receiptNote = Receipt2ReceiptNote(receipt);
                    receiptNote.PrintUrl = newUrl;
                    receiptNotes.Add(receiptNote);
                }
            }

            if (resolver.ReceiptNotes == null)
            {
                resolver.ReceiptNotes = receiptNotes;
            }
            else
            {
                IListHelper.AddRange <ReceiptNote>(resolver.ReceiptNotes, receiptNotes);
            }
        }
Пример #23
0
        private List <ReceiptNote> ConvertInProcessLocationsToReceiptNotes(IList <InProcessLocation> inProcessLocations)
        {
            if (inProcessLocations == null)
            {
                return(null);
            }
            int seq = 1;
            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();

            foreach (InProcessLocation inProcessLocation in inProcessLocations)
            {
                ReceiptNote receiptNote = new ReceiptNote();
                receiptNote.CreateDate = inProcessLocation.CreateDate;
                receiptNote.CreateUser = inProcessLocation.CreateUser == null ? string.Empty : inProcessLocation.CreateUser.Name;
                receiptNote.Dock       = inProcessLocation.DockDescription;
                receiptNote.IpNo       = inProcessLocation.IpNo;
                receiptNote.PartyFrom  = inProcessLocation.PartyFrom == null ? string.Empty : inProcessLocation.PartyFrom.Name;
                receiptNote.PartyTo    = inProcessLocation.PartyTo == null ? string.Empty : inProcessLocation.PartyTo.Name;
                receiptNote.Sequence   = seq;
                receiptNotes.Add(receiptNote);
                seq++;
            }
            return(receiptNotes);
        }
Пример #24
0
        public ReceiptNoteEntity Get(EmployeeEntity EmployeeEntity, Guid ReceiptNoteId)
        {
            ReceiptNote ReceiptNote = UnitOfWork.ReceiptNoteRepository.Get(ReceiptNoteId);

            return(new ReceiptNoteEntity(ReceiptNote, ReceiptNote.WareHouse, ReceiptNote.Supplier, ReceiptNote.ReceiptNoteLines));
        }
Пример #25
0
        /// <summary>
        /// auto generate id for all entities in Asowell Database
        /// all id type is 10 character and the sign is depend on the type of entity
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private TEntity AutoGeneteId_DBAsowell(TEntity entity)
        {
            string sign = "";

            if (entity is Employee)
            {
                sign = "EMP";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                Employee emp = entity as Employee;
                emp.EmpId = result;
            }
            else if (entity is AdminRe)
            {
                sign = "AD";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;


                AdminRe admin = entity as AdminRe;
                admin.AdId = result;
            }
            else if (entity is Customer)
            {
                sign = "CUS";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                Customer cus = entity as Customer;
                cus.CusId = result;
            }
            else if (entity is WareHouse)
            {
                sign = "WAH";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                WareHouse wh = entity as WareHouse;
                wh.WarehouseId = result;
            }
            else if (entity is Ingredient)
            {
                sign = "IGD";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                Ingredient ign = entity as Ingredient;
                ign.IgdId = result;
            }
            else if (entity is Product)
            {
                sign = "P";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                Product p = entity as Product;
                p.ProductId = result;
            }
            else if (entity is ProductDetail)
            {
                sign = "PD";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                ProductDetail pd = entity as ProductDetail;
                pd.PdetailId = result;
            }
            else if (entity is OrderNote)
            {
                sign = "ORD";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                OrderNote ord = entity as OrderNote;
                ord.OrdernoteId = result;
            }
            else if (entity is ReceiptNote)
            {
                sign = "RN";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                ReceiptNote rcn = entity as ReceiptNote;
                rcn.RnId = result;
            }
            else if (entity is SalaryNote)
            {
                sign = "SAN";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                SalaryNote sln = entity as SalaryNote;
                sln.SnId = result;
            }
            else if (entity is WorkingHistory)
            {
                sign = "WOH";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                WorkingHistory wh = entity as WorkingHistory;
                wh.WhId = result;
            }


            else if (entity is StockOut)
            {
                sign = "STO";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                StockOut stkout = entity as StockOut;
                stkout.StockOutId = result;
            }
            else if (entity is StockIn)
            {
                sign = "STI";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                StockIn stkIn = entity as StockIn;
                stkIn.Si_id = result;
            }
            else if (entity is APWareHouse)
            {
                sign = "APW";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                APWareHouse wh = entity as APWareHouse;
                wh.APWarehouseId = result;
            }
            else if (entity is Stock)
            {
                sign = "STK";
                // lấy số thứ tự mới nhất
                string numberWantToset = (this.Get().Count() + 1).ToString();

                int    blank  = ID_SIZE_DBASOWELL - (sign.Length + numberWantToset.Length);
                string result = sign;
                for (int i = 0; i < blank; i++)
                {
                    result += "0";
                }
                result += numberWantToset;

                Stock stock = entity as Stock;
                stock.StoId = result;
            }



            return(entity);
        }
 public void Update(ReceiptNote entity)
 {
     _receiptNoteRepository.Update(entity);
 }
 public void Insert(ReceiptNote entity)
 {
     _receiptNoteRepository.Insert(entity);
 }
 public ReceiptNote Add(ReceiptNote entity)
 {
     return(_receiptNoteRepository.Add(entity));
 }
Пример #29
0
        public frmReceipt()
        {
            InitializeComponent();
            //Load
            Load += (sender, e) =>
            {
                if (receiptNote == null)
                {
                    receiptNote = new ReceiptNote {
                        Date = DateTime.Now
                    }
                }
                ;
                //bind combobox
                LoadStaff();
                LoadSupplier();
                LoadStock();
                //bind gridview
                LoadRepositoryLookupEdit();
                listReceiptNoteDetails = receiptNote.ReceiptNoteDetails.ToList();
                //bind gridview to static list
                gcReceiptNoteDetails.DataSource = listReceiptNoteDetails;
            };
            //Add item gridview
            gvReceiptNoteDetails.DoubleClick += (sender, e) =>
            {
                listReceiptNoteDetails.Add(new ReceiptNoteDetail());
                gcReceiptNoteDetails.RefreshDataSource();
            };
            //Remove item gridview
            gvReceiptNoteDetails.KeyDown += (sender, e) =>
            {
                if (e.KeyValue == 46) //keyboard delete
                {
                    var currentItem = gvReceiptNoteDetails.GetFocusedRow() as ReceiptNoteDetail;
                    //delete from list
                    listReceiptNoteDetails.Remove(currentItem);
                    //rebinding gridview
                    gcReceiptNoteDetails.RefreshDataSource();
                }
            };
            //Produce add button click
            btnProduceAdd.Click += (sender, e) =>
            {
                frmProduce frm = new frmProduce();
                frm.OnSaved += t =>
                {
                    var produce = t as Produce;
                    unitOfWork.ProduceService.Create(produce);
                    unitOfWork.Save();
                    //reload repository produce
                    LoadRepositoryLookupEdit();
                    frm.Close();
                };
                frm.ShowDialog();
            };
            //Staff add button click
            btnStaffAdd.Click += (sender, e) =>
            {
                frmStaff frm = new frmStaff();
                frm.OnSaved += t =>
                {
                    unitOfWork.StaffService.Create(t as Staff);
                    unitOfWork.Save();
                    //reload combobox
                    LoadStaff();
                    frm.Close();
                };
                frm.ShowDialog();
            };
            //Supplier add button click
            btnSupplierAdd.Click += (sender, e) =>
            {
                frmSupplier frm = new frmSupplier();
                frm.OnSaved += t =>
                {
                    unitOfWork.SupplierService.Create(t as Supplier);
                    unitOfWork.Save();
                    //reload combobox
                    LoadSupplier();
                    frm.Close();
                };
                frm.ShowDialog();
            };
            //Stock add button click
            btnStockAdd.Click += (sender, e) =>
            {
                frmStock frm = new frmStock();
                frm.OnSaved += t =>
                {
                    unitOfWork.StockService.Create(t as Stock);
                    unitOfWork.Save();
                    //reload combobox
                    LoadStock();
                    frm.Close();
                };
                frm.ShowDialog();
            };
            //Save button click
            ucActionResultButton.SaveButtonClick += (sender, e) =>
            {
                if (dxValidationProvider.Validate())
                {
                    var listItem = gvReceiptNoteDetails.DataSource as List <ReceiptNoteDetail>;
                    if (listItem.Count > 0)
                    {
                        receiptNote.ReceiptNoteDetails = listItem;
                        OnSaved(receiptNote);
                    }
                }
            };
            //Cancel button click
            ucActionResultButton.CancelButtonClick += (sender, e) =>
            {
                this.Close();
            };

            //validate row item
            gvReceiptNoteDetails.ValidateRow += (sender, e) =>
            {
                GridView view = sender as GridView;
                //GridColumn colProduceId = view.Columns[0];
                GridColumn colQuantity = view.Columns[1];
                GridColumn colPrice    = view.Columns[2];

                //validate for quanity > 1
                var quanity = (int)view.GetRowCellValue(e.RowHandle, colQuantity);
                if (quanity < 1)
                {
                    e.Valid = false;
                    view.SetColumnError(colQuantity, "Số lượng nhập phải lớn hơn 0");
                    return;
                }
                var price = (decimal)view.GetRowCellValue(e.RowHandle, colPrice);
                if (price < 1000)
                {
                    e.Valid = false;
                    view.SetColumnError(colPrice, "Giá sản phẩm phải lớn hơn 1000đ");
                    return;
                }
            };
        }