private void cmbItemCode_EditValueChanged(object sender, EventArgs e)
 {
     try
     {
         if (cmbItemCode.EditValue != null)
         {
             txtItemName.EditValue = cmbLookupView.GetFocusedRowCellValue("ITEMNAME");
             cmbCategory.EditValue = cmbLookupView.GetFocusedRowCellValue("CATEGORYID");
             if (cmbCategory.EditValue.Equals(3) || cmbCategory.EditValue.Equals(4))
             {
                 dtpPackedDate.Enabled  = true;
                 txtBatchNumber.Enabled = true;
             }
             DataTable dtMRPList = objItemRep.GetMRPList(cmbItemCode.EditValue);
             if (dtMRPList.Rows.Count > 1)
             {
                 frmMRPList obj = new frmMRPList(dtMRPList);
                 obj.ShowDialog();
                 if (obj._IsSave)
                 {
                     txtMRP.EditValue       = ((DataRowView)obj.drSelected)["MRP"];
                     txtSalePrice.EditValue = ((DataRowView)obj.drSelected)["SALEPRICE"];
                 }
             }
             else
             {
                 txtMRP.EditValue       = dtMRPList.Rows[0]["MRP"];
                 txtSalePrice.EditValue = dtMRPList.Rows[0]["SALEPRICE"];
             }
             txtQuantity.EditValue = 1;
         }
     }
     catch (Exception ex)
     {
         ErrorMgmt.ShowError(ex);
         ErrorMgmt.Errorlog.Error(ex);
     }
 }
        private void txtItemCode_Properties_Leave(object sender, EventArgs e)
        {
            // do not load again unless code changes
            if (isEditMode && itemObj.ItemCode.Equals(txtItemCode.EditValue))
            {
                return;
            }

            if (string.IsNullOrEmpty(Convert.ToString(txtItemCode.EditValue)))
            {
                ClearUI();
                return;
            }

            int rowHandle = gvItemCode.LocateByValue("ITEMCODE", txtItemCode.EditValue);

            // if the scanned item is already existing, go into edit mode
            if (rowHandle != GridControl.InvalidRowHandle)
            {
                gvItemCode.FocusedRowHandle = rowHandle;
                itemObj.ItemCodeID          = gvItemCode.GetFocusedRowCellValue("ITEMCODEID");
            }
            else
            {
                ClearUI();
                return;
            }

            DataSet dsItemDetails = new ItemCodeRepository().GetItemCode(itemObj.ItemCodeID, Utility.CategoryID);

            DataTable dtItemDetails = dsItemDetails.Tables["ITEMCODEDETAIL"];

            if (dtItemDetails.Rows.Count == 0)
            {
                ClearUI();
                return;
            }

            isLoading             = true;
            txtHSNCode.EditValue  = dtItemDetails.Rows[0]["HSNCODE"];
            chkIsEAN.EditValue    = dtItemDetails.Rows[0]["ISEAN"];
            sluSKUCode.EditValue  = dtItemDetails.Rows[0]["ITEMID"];
            txtItemName.EditValue = dtItemDetails.Rows[0]["ITEMNAME"];
            Text             = "Edit Item - " + txtItemName.Text;
            itemObj.ItemID   = dtItemDetails.Rows[0]["ITEMID"];
            itemObj.ItemCode = dtItemDetails.Rows[0]["ITEMCODE"];
            //txtDescription.EditValue = dtItemDetails.Rows[0]["DESCRIPTION"];
            gluCategory.EditValue   = dtItemDetails.Rows[0]["CATEGORYID"];
            chkIsOpenItem.EditValue = dtItemDetails.Rows[0]["ISOPENITEM"];
            sluParentItem.EditValue = dtItemDetails.Rows[0]["PARENTITEMID"];
            luSubCategory.EditValue = dtItemDetails.Rows[0]["SUBCATEGORYID"];
            luUOM.EditValue         = dtItemDetails.Rows[0]["UOMID"];
            sluFreeItem.EditValue   = dtItemDetails.Rows[0]["FREEITEMCODEID"];

            DataTable dtItemCodePrices = dsItemDetails.Tables["ITEMCODEPRICES"];
            DataRow   selectedPrice    = dtItemCodePrices.Rows[0];

            if (dtItemCodePrices.Rows.Count > 1)
            {
                frmMRPList frmMRPList = new frmMRPList(dtItemCodePrices);
                frmMRPList.ShowDialog();
                if (!frmMRPList._IsSave)
                {
                    ClearUI();
                    return;
                }

                selectedPrice = (frmMRPList.drSelected as DataRowView).Row;
            }

            txtCostPriceWT.EditValue  = selectedPrice["COSTPRICEWT"];
            txtCostPriceWOT.EditValue = selectedPrice["COSTPRICEWOT"];
            txtSalePrice.EditValue    = selectedPrice["SALEPRICE"];
            txtMRP.EditValue          = selectedPrice["MRP"];
            luGST.EditValue           = selectedPrice["GSTID"];

            isLoading  = false;
            isEditMode = true;
        }