Ejemplo n.º 1
0
        private void lkeInternalCode_EditValueChanged(object sender, EventArgs e)
        {
            if (lkeInternalCode.EditValue == null)
            {
                return;
            }

            InventoryItem_cu inventoryItem = InventoryBusinessLogicEngine.GetInventoryItem(lkeInternalCode.EditValue);

            if (inventoryItem != null)
            {
                lkeInventoryItems.EditValue = inventoryItem.ID;
            }

            btnCalculate_Click(null, null);
        }
Ejemplo n.º 2
0
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            if (lkeInventoryItems.EditValue == null && lkeInternalCode.EditValue == null)
            {
                XtraMessageBox.Show("يجـــب إختيـــار المنتــج", "تنبيـــه", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1, DefaultBoolean.Default);
                return;
            }

            InventoryItem_cu selectedItem = null;

            if (lkeInventoryItems.EditValue != null || lkeInternalCode.EditValue == null)
            {
                selectedItem = InventoryBusinessLogicEngine.GetInventoryItem(lkeInventoryItems.EditValue);
            }
            else if (lkeInventoryItems.EditValue == null || lkeInternalCode.EditValue != null)
            {
                selectedItem = InventoryBusinessLogicEngine.GetInventoryItem(lkeInternalCode.EditValue);
            }

            if (selectedItem == null)
            {
                XtraMessageBox.Show("هـــذا المنـــج غيـــر مـوجــــــود", "تنبيـــه", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1, DefaultBoolean.Default);
                return;
            }

            List <InventoryItem_Area> areaList = InventoryItem_Area.ItemsList.FindAll(item =>
                                                                                      Convert.ToInt32(item.InventoryItemID).Equals(Convert.ToInt32(selectedItem.ID)));
            List <InventoryItem_RawMaterial_cu> rawMaterialsList = InventoryItem_RawMaterial_cu.ItemsList.FindAll(item =>
                                                                                                                  Convert.ToInt32(item.InventoryItem_CU_ID).Equals(Convert.ToInt32(selectedItem.ID)));
            List <InventoryItem_Printing_cu> printingList;

            if (rawMaterialsList.Count != 0)
            {
                printingList = InventoryBusinessLogicEngine.GetInventoryItem_Printing_List(selectedItem);
            }
            else
            {
                printingList = InventoryItem_Printing_cu.ItemsList.FindAll(item =>
                                                                           Convert.ToInt32(item.InventoryItem_CU_ID).Equals(Convert.ToInt32(selectedItem.ID)));
                XtraMessageBox.Show("المنتـــج غيـــر مـربــوط بمــــواد الخــــام", "تنبيـــه", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1, DefaultBoolean.Default);
            }
            List <InventoryItem_Color_cu> colorsList = InventoryItem_Color_cu.ItemsList.FindAll(item =>
                                                                                                Convert.ToInt32(item.InventoryItem_CU_ID).Equals(Convert.ToInt32(selectedItem.ID)));

            grd_AreaParts.DataSource    = areaList;
            grd_Printing.DataSource     = printingList.OrderByDescending(item => item.Date);
            grd_RawMaterials.DataSource = rawMaterialsList;
            grd_Color.DataSource        = colorsList;

            spnTotalParts.EditValue       = InventoryBusinessLogicEngine.GetInventoryItemTotalCountParts(selectedItem);
            spnTotalAreaParts.EditValue   = InventoryBusinessLogicEngine.GetInventoryItemTotalAreaParts(selectedItem);
            spnPrintingUnitCost.EditValue = InventoryBusinessLogicEngine.GetPrintingCost(printingList);
            spnRawMaterialsCost.EditValue = InventoryBusinessLogicEngine.GetRawMaterialsCost(rawMaterialsList);
            spnRawMaterialsArea.EditValue = InventoryBusinessLogicEngine.GetRawMaterialsTotalArea(rawMaterialsList);

            spnTotalCost.EditValue = Convert.ToDouble(spnRawMaterialsCost.EditValue) +
                                     Convert.ToDouble(spnPrintingUnitCost.EditValue);
        }