private void simpleButton1_Click(object sender, EventArgs e)
        {
            var dt = (DataView) gridView1.DataSource;
            dt.RowFilter = "Requested >0";
            if (dt == null) return;
            var po = new PO();
            po.AddNew();
            var serverDateTime = DateTimeHelper.ServerDateTime;
            po.PODate = serverDateTime;
            po.DateOfEntry = serverDateTime;
            po.PurchaseType = POType.INTERNAL;
            po.PaymentTypeID = PaymentType.Constants.STV;
            po.TermOfPayement = TermOfPayment.List[6].ID;
            po.PurchaseOrderStatusID = 9; //PurchaseOrderStatus ==> Processed
            po.SavedbyUserID = CurrentContext.LoggedInUser.ID;
            po.Save();
            var purchaseOrderDetail = new PurchaseOrderDetail();
            foreach (DataRowView dr in dt)
            {
                var itemUnit = new ItemUnitBase();
                itemUnit.LoadByPrimaryKey(Convert.ToInt32(dr["UnitID"]));

                purchaseOrderDetail.AddNew();
                purchaseOrderDetail.ItemID = Convert.ToInt32(dr["ItemID"]);
                purchaseOrderDetail.UnitOfIssueID = itemUnit.UnitOfIssueID;
                purchaseOrderDetail.Quantity = Convert.ToInt32(dr["Requested"]);
                purchaseOrderDetail.PurchaseOrderID = po.ID;
                purchaseOrderDetail.Rowguid = Guid.NewGuid();
                purchaseOrderDetail.ApprovedQuantity = 0;

            }
            purchaseOrderDetail.Save();
            lookUpEdit1_EditValueChanged(null, null);
        }
コード例 #2
0
        public static PO CreatePOforStandard(int orderType, int StoreID, int?SupplierID, string Remark, int userID)
        {
            BLL.PO po = new PO();
            po.AddNew();


            po.StoreID = StoreID;

            po.ExhangeRate = 1;
            po.Insurance   = 0;
            po.Description = Remark;
            if (SupplierID != null)
            {
                po.SupplierID = Convert.ToInt32(SupplierID);
            }

            //po.PurchaseType =
            po.SavedbyUserID = userID;
            po.IsElectronic  = false;
            po.POFinalized   = false;
            po.Rowguid       = Guid.NewGuid();
            po.Identifier    = "00000";
            po.DateOfEntry   = DateTimeHelper.ServerDateTime;
            UpdatePoNumberAndPOType(orderType, po);
            po.Save();
            //~ Update PONumber for Transfers and Error Correction ~//
            UpdatePoNumberAndPOType(orderType, po);
            po.Save();

            return(po);
        }
コード例 #3
0
        public static void SaveList(List <HCMIS.Desktop.STVSyncService.STVList> list, int userID)
        {
            BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice();
            foreach (HCMIS.Desktop.STVSyncService.STVList v in list)
            {
                // try to load by primary key
                bv.LoadBySTVNoAndAccountType(v.STVNo, v.AccountID);

                // if the entry doesn't exist, create it
                if (bv.RowCount == 0)
                {
                    BLL.PO po = new BLL.PO();
                    po.AddNew();
                    if (v.AccountID.HasValue)
                    {
                        po.StoreID = v.AccountID.Value;
                    }
                    po.SupplierID = BLL.Supplier.CONSTANTS.HOME_OFFICE;
                    if (v.HubID.HasValue)
                    {
                        po.PONumber = v.HubID.Value + "-" + v.STVNo;
                    }
                    po.Save();

                    bv.AddNew();
                    bv.STVOrInvoiceNo = v.STVNo.ToString();
                    bv.InvoiceTypeID  = BLL.ReceiptInvoiceType.InvoiceType.STV;
                    bv.DateOfEntry    = DateTimeHelper.ServerDateTime;
                    bv.POID           = po.ID;
                    bv.SavedByUserID  = userID;
                }
                // populate the contents of v on the to the database list
                bv.TotalValue    = v.InvoiceTotalValue;
                bv.Insurance     = v.Insurance;
                bv.SavedByUserID = userID;
                bv.Save();
            }
        }
コード例 #4
0
        private int SaveRelevantReceiptHeaders(int receiptTypeID, int warehouseID)
        {
            int receiptID;
            var receipt = new BLL.Receipt();
            var sup = new BLL.Supplier();

            if (lkReceiptInvoice.EditValue != null && Convert.ToInt32(lkReceiptInvoice.EditValue) != -1)
            {
                receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, CurrentContext.UserId,
                    Convert.ToInt32(lkReceiptInvoice.EditValue), txtEditTransferNo.Text,
                    ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);
                // , txtTransitNo.Text, txtInsuranceNo.Text, txtWayBillNo.Text);
            }
            else
            {
                //PO and ReceiptInvoice created automatically.
                //Needs to be fixed.
                BLL.PO po = new PO();
                BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();

                po.AddNew();
                var serverDateTime = DateTimeHelper.ServerDateTime;
                po.PODate = serverDateTime;
                po.DateOfEntry = serverDateTime;
                po.PurchaseType = POType.INVENTORY;
                po.IsElectronic = false;
                po.POFinalized = false;
                po.Rowguid = Guid.NewGuid();
                po.Identifier = "00000";

                po.PaymentTypeID = BLL.PaymentType.Constants.STV;
                po.TermOfPayement = BLL.PaymentTerm.Internal;
                po.PurchaseOrderStatusID = PurchaseOrderStatus.Processed;

                rctInvoice.AddNew();

                po.StoreID = Convert.ToInt32(lkAccounts.EditValue);
                Activity acc = new Activity();
                acc.LoadByPrimaryKey(po.StoreID);
                po.ModeID = acc.ModeID;

                //po.PONumber = srm ? lkSTVInvoiceNo.EditValue.ToString() : (deliveryNote ? txtRefNo.Text : (beginningBalance ? "BeginningBalance" : String.Empty));

                if (lcSTVNo.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always)
                {
                    po.PONumber = srm && !chkSRMForOldSystemIssues.Checked
                        ? txtSTVNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtSTVNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtRefNo.Text)));
                }
                else
                {
                    po.PONumber = srm && !chkSRMForOldSystemIssues.Checked
                        ? lkSTVInvoiceNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtRefNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtRefNo.Text)));
                }

                   //TODO: Ugly hack, supplier. To be fixed.
                    if (srm)
                    {
                        po.SupplierID = BLL.Supplier.CONSTANTS.RETURNED_FROM_FACILITY;

                        //Let's put Finance Required stuff here.
                        po.Insurance = 0;
                        po.ExhangeRate = 1;
                        rctInvoice.ExchangeRate = 1;
                        rctInvoice.Insurance = 0;

                        rctInvoice.InvoiceTypeID = ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE;

                        if (chkSRMForOldSystemIssues.Checked)
                        {
                            if (lkForFacility.EditValue == null)
                                throw new Exception("Facility not chosen!");
                            po.RefNo = lkForFacility.EditValue.ToString();
                        }
                    }

                po.SavedbyUserID = CurrentContext.LoggedInUser.ID;
                po.Save();

                rctInvoice.POID = po.ID;
                if (lcSTVNo.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always)
                {
                    rctInvoice.STVOrInvoiceNo = srm && !chkSRMForOldSystemIssues.Checked
                        ? txtSTVNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtSTVNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtSTVNo.Text)));
                }
                else
                {
                    rctInvoice.STVOrInvoiceNo = srm && !chkSRMForOldSystemIssues.Checked
                        ? lkSTVInvoiceNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtRefNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtRefNo.Text)));
                }
                rctInvoice.DateOfEntry = DateTimeHelper.ServerDateTime;
                rctInvoice.ActivityID = po.StoreID;
                rctInvoice.SavedByUserID = CurrentContext.LoggedInUser.ID;
                rctInvoice.IsDeliveryNote = false;

                rctInvoice.Rowguid = Guid.NewGuid();
                rctInvoice.PrintedDate = po.DateOfEntry;
                rctInvoice.IsVoided = false;
                rctInvoice.ShippingSite = " ";
                rctInvoice.IsConvertedFromDeliveryNote = false;
                rctInvoice.IsDeliveryNote = false;
                rctInvoice.DocumentTypeID = DocumentType.CONSTANTS.SRM;

                rctInvoice.Save();

                receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, CurrentContext.UserId, rctInvoice.ID,
                    txtTransitTransferVoucherNo.Text, ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);

                //receiptID = receipt.AddNewReceipt(receiptTypeID, NewMainWindow.UserId);
            }
            return receiptID;
        }
コード例 #5
0
        public static PO CreatePOforStandard(int orderType, int StoreID, int? SupplierID, string Remark,int userID)
        {
            BLL.PO po = new PO();
            po.AddNew();

            po.StoreID = StoreID;

            po.ExhangeRate = 1;
            po.Insurance = 0;
            po.Description = Remark;
            if (SupplierID != null)
                po.SupplierID = Convert.ToInt32(SupplierID);

            //po.PurchaseType =
            po.SavedbyUserID = userID;
            po.IsElectronic = false;
            po.POFinalized = false;
            po.Rowguid = Guid.NewGuid();
            po.Identifier = "00000";
            po.DateOfEntry = DateTimeHelper.ServerDateTime;
            UpdatePoNumberAndPOType(orderType, po);
             po.Save();
            //~ Update PONumber for Transfers and Error Correction ~//
            UpdatePoNumberAndPOType(orderType, po);
            po.Save();

            return po;
        }
コード例 #6
0
        private void btnSaveOrder_Click(object sender, EventArgs e)
        {
            if (dxValidation.Validate())
            {
                var po = new PO();
                if (PoID != 0)
                {
                    po.LoadByPrimaryKey(PoID);
                }
                else
                {
                    po.AddNew();
                }
                if (PoID == 0 && po.DoesPONumberExists(txtOrderInformation.Text))
                {
                    XtraMessageBox.Show(string.Format(@"There is an existing Order with the same OrderNo as {0}. Please try to use another OrderNo!",txtOrderInformation.Text), "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (PoID == 0) po.PONumber = txtOrderInformation.Text;
                po.TotalValue = Convert.ToDouble(txtTotalValue.EditValue);
                po.Insurance = Convert.ToDouble(txtInsurance.EditValue);
                po.OtherExpense = Convert.ToDouble(txtInsuredSum.EditValue);
                po.NBE = Convert.ToDouble(txtNBEServiceCharge.EditValue);
                po.SupplierID = Convert.ToInt32(lkSupplier.EditValue);
                po.SavedbyUserID = CurrentContext.LoggedInUser.ID;
                //Make PurchaseType Default Value to Internale ID = 8
                //po.PurchaseType = Convert.ToInt32(gridLkEditOrderType.EditValue) == 0 || Convert.ToInt32(gridLkEditOrderType.EditValue) == null ? POType.GetAllPOTypes().Find(pot=>pot.ID == POType.INTERNAL).ID : Convert.ToInt32(gridLkEditOrderType.EditValue);
                po.PurchaseType =  Convert.ToInt32(gridLkEditOrderType.EditValue);
                po.StoreID = Convert.ToInt32(grdLkEditAccounts.EditValue);
                po.ExhangeRate =Convert.ToDouble(txtExchangeRate.EditValue);
                po.RefNo = txtRefNo.EditValue.ToString();

                po.Delivery = txtDelivery.EditValue != null ? txtDelivery.EditValue.ToString() : "";
                if (txtFreight.EditValue != null)
                {
                    po.AirFreight = Convert.ToDouble(txtFreight.EditValue);
                }
                po.Description = txtDescription.EditValue != null ? txtDescription.EditValue.ToString() : "";

                var serverDateTime = DateTimeHelper.ServerDateTime;
                po.PODate = serverDateTime;
                po.DateOfEntry = serverDateTime;
                po.LCID = Convert.ToInt32(lkCurrencyLCID.EditValue);
                //Make TermOfPayment Default to Internal , ID = 7,
                //po.TermOfPayement = Convert.ToInt32(lkTermOfPayement.EditValue) == 0 || Convert.ToInt32(lkTermOfPayement.EditValue) == null ? TermOfPayment.List[6].ID : Convert.ToInt32(lkTermOfPayement.EditValue);
                po.TermOfPayement = Convert.ToInt32(lkTermOfPayement.EditValue) == 0 || Convert.ToInt32(lkTermOfPayement.EditValue) == null ? PaymentTerm.Internal : Convert.ToInt32(lkTermOfPayement.EditValue);
                po.PaymentTypeID = PaymentType.Constants.STV;
                po.PurchaseOrderStatusID = PurchaseOrderStatus.Processed; //PurchaseOrderStatus ==> Processed

                po.IsElectronic = false;
                po.POFinalized = false;
                po.Rowguid = Guid.NewGuid();
                po.Identifier = "00000";

                var acc = new Activity();
                acc.LoadByPrimaryKey(po.StoreID);
                po.ModeID = acc.ModeID;
                po.Save();

                this.LogActivity("Save-PO", po.ID);
                this.DialogResult = DialogResult.Yes;
                this.Close();

            }
        }
コード例 #7
0
        public static void SaveList(List<HCMIS.Desktop.STVSyncService.STVList> list, int userID)
        {
            BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice();
            foreach (HCMIS.Desktop.STVSyncService.STVList v in list)
            {
                // try to load by primary key
                bv.LoadBySTVNoAndAccountType(v.STVNo, v.AccountID);

                // if the entry doesn't exist, create it
                if (bv.RowCount == 0)
                {
                    BLL.PO po = new BLL.PO();
                    po.AddNew();
                    if (v.AccountID.HasValue)
                        po.StoreID = v.AccountID.Value;
                    po.SupplierID = BLL.Supplier.CONSTANTS.HOME_OFFICE;
                    if (v.HubID.HasValue)
                        po.PONumber = v.HubID.Value + "-" + v.STVNo;
                    po.Save();

                    bv.AddNew();
                    bv.STVOrInvoiceNo = v.STVNo.ToString();
                    bv.InvoiceTypeID = BLL.ReceiptInvoiceType.InvoiceType.STV;
                    bv.DateOfEntry = DateTimeHelper.ServerDateTime;
                    bv.POID = po.ID;
                    bv.SavedByUserID = userID;
                }
                // populate the contents of v on the to the database list
                bv.TotalValue = v.InvoiceTotalValue;
                bv.Insurance = v.Insurance;
                bv.SavedByUserID = userID;
                bv.Save();
            }
        }