private void cmbItem_SelectedIndexChanged(object sender, EventArgs e) { //txtGRNUnitCost.Text = "0.0"; // cmbGRNNO.Text = ""; Material objMat = new Material(); BasicProduct objBasic = new BasicProduct(); FinishProduct objFinish = new FinishProduct(); Store objStore = new Store(); Stock_DL objStockDL = new Stock_DL(ConnectionStringClass.GetConnection()); try { String ItemCode = ""; txtUnit.Text = ""; txtAvailableQty.Text = ""; if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null) { ItemCode = cmbItem.SelectedValue.ToString(); objStore = (Store)cmbStoreFrom.SelectedItem; if (cmbMTNType.SelectedItem.Equals("Material")) { objMat = objMaterialDL.Get(ItemCode); txtUnit.Text = objMat.MatUnit.UnitName; //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_Material(objStore.StoreID, ItemCode).ToString(); txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.Material).ToString(); } else if (cmbMTNType.SelectedItem.Equals("Basic Product")) { objBasic = objBasicProductDL.Get(ItemCode); txtUnit.Text = objBasic.BasicProductUnit.UnitName; //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_BasicProduct(objStore.StoreID, ItemCode).ToString(); txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.BasicProduct).ToString(); } else if (cmbMTNType.SelectedItem.Equals("Finish Product")) { objFinish = objFinishProductDL.Get(ItemCode); txtUnit.Text = objFinish.FinishProductPackingType.PackingTitle; //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_FinishProduct(objStore.StoreID, ItemCode).ToString(); txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.FinishProduct).ToString(); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button2_Click(object sender, EventArgs e) { try { DialogResult dr = MessageBox.Show(this, "Are you sure you want to Dispatch Items in the List? Click Yes to continue", "Confirm Dispatch", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { objDispatch.DispatchNoteDate = dtDispatchOrderDate.Value; objDispatch.DispatchNoteEnterdBy = CurrentUser.UserEmp; objDispatch.DispatchNoteEnterdDate = DateTime.Now; objDispatch.DispatchNoteID = txtDispatchNoteNo.Text; bool IsStock = true; foreach (DispatchProducts obj in objDispatchProductCollec) { Decimal qty = objStockDL.GetAvailableQty("MAIN", obj.DispatchFinishProduct.FinishProductCode, Stock.Type.FinishProduct); if (qty < obj.DispatchQty) { IsStock = false; break; } } if (IsStock) { //int x = objDispathcNoteDL.Add(objDispatch); //if (x > 0) //{ // foreach (DispatchProducts obj in objDispatchProductCollec) // { // obj.DispatchNote = objDispatch; // int y = objDispatchProductDL.Add(obj); // if (y == -1) // { // MessageBox.Show(this, "Stock is below than dispatch," + obj.DispatchFinishProduct.Code + " will not be dispatched", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // } // } //} //this.Close(); } else { MessageBox.Show(this, "Current Stock low, Please Try other time", "Insufficient Stock", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }