示例#1
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (ReadOnly)
            {
                return;
            }


            var productLocation = ProductLocationManager.GetVWByBranchAndDate(BranchID, Date);

            DataSetHelper.DeleteAllRows(ds_WarehouseDescription.SP_GetWarehouseDescriptionDetail);

            short i         = 0;
            var   rate      = CurrencyRate;
            var   id        = WarehouseDescriptionID;
            var   t_product = new DS_PurchaseOrderInfo.T_ProductDataTable();

            foreach (var row in productLocation)
            {
                i++;
                var newRow = ds_WarehouseDescription.SP_GetWarehouseDescriptionDetail.NewSP_GetWarehouseDescriptionDetailRow();
                newRow.WarehouseDescriptionID = id;
                newRow.OrdinalNumber          = i;
                newRow.MedicamentID           = row.MedicamentID;
                newRow.MedicamentName         = row.MedicamentName;
                newRow.UnitsInStock           = row.UnitsInStock;
                newRow.ProductID = row.ProductID;
                newRow[ds_WarehouseDescription.SP_GetWarehouseDescriptionDetail.CountryCodeColumn] = row[productLocation.CountryCodeColumn.ColumnName];
                newRow[ds_WarehouseDescription.SP_GetWarehouseDescriptionDetail.BrandIDColumn]     = row[productLocation.BrandIDColumn];
                newRow.UnitPrice = row.StandardCost * rate;
                newRow.Quantity  = row.Quantity;
                newRow.DescrQty  = 0m;
                ds_WarehouseDescription.SP_GetWarehouseDescriptionDetail.AddSP_GetWarehouseDescriptionDetailRow(newRow);
                t_product.AddT_ProductRow(row.ProductID);
            }

            DataTable t_xml        = DataSetHelper.PackAlternationDataTable(t_product);
            var       purchaseInfo = ProductionManager.GetPurchaseOrderInfo(0, CurrencyCode, DataSetHelper.InnerBytesData(t_xml));
            var       view         = new DataView(purchaseInfo);

            view.Sort = purchaseInfo.ProductIDColumn.ColumnName;

            foreach (var row in ds_WarehouseDescription.SP_GetWarehouseDescriptionDetail)
            {
                if (DataSetHelper.IsDataRowDeleted(row))
                {
                    continue;
                }

                var j = view.Find(row.ProductID);
                if (j == -1)
                {
                    continue;
                }

                var purchaseRow = (DS_PurchaseOrderInfo.SP_GetPurchaseOrderInfoRow)view[j].Row;
                row.UnitPrice = ProductionManager.GetPurchaseUnitPrice(purchaseRow.UnitPrice, purchaseRow.AverageRate1, purchaseRow.AverageRate2);
            }
        }
示例#2
0
        public void OnChooseProduct(object sender, CancelEventArgs e)
        {
            if (ReadOnly || OptionsBaseForm.IsLoading || OptionsBaseForm.IsClosing)
            {
                return;
            }

            try
            {
                var frm = (sender as frmBrowse);

                if (frm == null)
                {
                    return;
                }

                if (frm.OptionsGrid.SelectedRecordID == null)
                {
                    throw new NullReferenceException("არჩეული ჩანაწერის იდენთიფიკატორი ცარიელია. (frm.SelectedRecordID = null)");
                }

                var table = ProductLocationManager.GetVWByIDAndBranch(ConvertHelper.ToInt32(frm.OptionsGrid.SelectedRecordID), FromBranchID, true);
                if (table.Count == 0)
                {
                    throw new NullReferenceException("ჩანაწერი ვერ ვიპოვე მონაცემთა ბაზაში.");
                }

                var crossRate = table[0].ProductCurrencyRate / CurrencyRate;
                table[0].StandardCost = ProductionManager.GetPurchaseUnitPrice(table[0].ProductID, CurrencyCode) / crossRate;
                e.Cancel = !AddDetail(table[0]);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("შეცდომა მონაცემის არჩევისას.\n" + ex.Message, "შეცდომა", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }