protected void btnSave_Click(object sender, EventArgs e) { Page.Validate("AddEdit"); if (Page.IsValid) { try { if (Detail.Count == 0) { WebFormHelper.SetLabelTextWithCssClass(lblStatusAddEdit, "Cannot save empty detail", LabelStyleNames.ErrorMessage); return; } foreach (GridItem row in grdDetail.Items) { int itemID = Convert.ToInt32(((Label)row.FindControl("lblQtyPO")).Text); ReceivingDetailViewModel detail = Detail.Single(x => x.ItemID == itemID); detail.QtyReceived = Convert.ToInt32(((RadNumericTextBox)row.FindControl("txtQtyReceived")).Value); detail.Notes = ((RadTextBox)row.FindControl("txtNotes")).Text; } string result = ReceiveService.AddOrUpdateReceiving( RowID, Convert.ToInt32(hidPOID.Value), receivingDate.SelectedDate.GetValueOrDefault(), txtGoodIssueNo.Text, txtFreightInfo.Text, Convert.ToInt32(ddlWarehouse.SelectedValue), txtNotes.Text, Detail); btnPrint.Enabled = true; ReloadCurrentPage(); } catch (Exception ex) { WebFormHelper.SetLabelTextWithCssClass(lblStatusAddEdit, ex.Message, LabelStyleNames.ErrorMessage); LogService.ErrorException(GetType().FullName, ex); } } }
protected void btnSave_Click(object sender, EventArgs e) { Page.Validate("AddEdit"); if (Page.IsValid) { try { if (Detail.Count == 0) { WebFormHelper.SetLabelTextWithCssClass(lblStatusAddEdit, "Cannot save empty detail", LabelStyleNames.ErrorMessage); return; } foreach (GridItem row in grdDetail.Items) { int itemID = Convert.ToInt32(((Label)row.FindControl("lblQtyPO")).Text); ReceivingDetailViewModel detail = Detail.Single(x => x.ItemID == itemID); detail.QtyReceived = Convert.ToDecimal(((RadNumericTextBox)row.FindControl("txtQtyReceived")).Value); detail.Notes = ((RadTextBox)row.FindControl("txtNotes")).Text; } // if (ReceiveService.CheckItemIsFullReceive(RowID, Convert.ToInt32(hidPOID.Value), Detail)) // { // WebFormHelper.SetLabelTextWithCssClass(lblStatusAddEdit, // @"Item receiving is not valid in qty or does not exist in // Purchase Order or surpass the item quantity in Purchase Order", // LabelStyleNames.ErrorMessage); // return; // } string result = ReceiveService.AddOrUpdateReceiving( RowID, Convert.ToInt32(hidPOID.Value), receivingDate.SelectedDate.GetValueOrDefault(), txtGoodIssueNo.Text, txtFreightInfo.Text, txtNotes.Text, Detail); btnPrint.Enabled = true; //if (result == "F") //{ // btnSave.Enabled = false; // btnVoid.Enabled = false; //} //ScriptManager.RegisterStartupScript(this, // this.GetType(), // "save", // String.Format("alert('Receiving has been saved');"), // true); ReloadCurrentPage(); } catch (Exception ex) { WebFormHelper.SetLabelTextWithCssClass(lblStatusAddEdit, ex.Message, LabelStyleNames.ErrorMessage); } } }