protected void btnUpdateBalance_Click(object sender, EventArgs e) { try { int hfId = CurrentEnvironment.LoggedUser.HealthFacilityId; string _hfId = (string)Request.QueryString["hfId"]; if (!String.IsNullOrEmpty(_hfId)) { int.TryParse(_hfId, out hfId); } foreach (GridViewRow gr in gvHealthFacilityBalance.Rows) { if (gr.RowType == DataControlRowType.DataRow) { TextBox txtQty = (TextBox)gr.FindControl("txtQty"); if (!string.IsNullOrEmpty(txtQty.Text)) { UInt32 qty = UInt32.Parse(txtQty.Text.Trim()); string gtin = gr.Cells[1].Text; string lotno = gr.Cells[3].Text; DateTime date = DateTime.ParseExact(txtDate.Text, ConfigurationDate.GetConfigurationDateById(int.Parse(Configuration.GetConfigurationByName("DateFormat").Value)).DateFormat.ToString(), CultureInfo.CurrentCulture); HealthFacility hf = HealthFacility.GetHealthFacilityById(hfId); StockManagementLogic sml = new StockManagementLogic(); ItemTransaction st = sml.StockCount(hf, gtin, lotno, qty, CurrentEnvironment.LoggedUser.Id, date); int i = st.Id; if (i > 0) { lblSuccess.Visible = true; lblError.Visible = false; } else { lblSuccess.Visible = false; lblError.Visible = true; } } } } odsHealthFacilityBalance.SelectParameters.Clear(); odsHealthFacilityBalance.SelectParameters.Add("id", hfId.ToString()); odsHealthFacilityBalance.DataBind(); } catch (Exception ex) { lblSuccess.Visible = false; lblError.Visible = true; } }
protected void btnAdd_Click(object sender, EventArgs e) { try { if (Page.IsValid) { int userId = CurrentEnvironment.LoggedUser.Id; //check for duplicates // ItemTransaction st = StockManagementLogic.StockCount(CurrentEnvironment.LoggedUser.HealthFacility.Code, ddlGtin.SelectedValue, ddlItemLot.SelectedValue, txtQuantity.Text, CurrentEnvironment.LoggedUser.Id); StockManagementLogic sml = new StockManagementLogic(); UInt32 qty = UInt32.Parse(txtQuantity.Text); DateTime date = DateTime.ParseExact(txtStockCountDate.Text, ConfigurationDate.GetConfigurationDateById(int.Parse(Configuration.GetConfigurationByName("DateFormat").Value)).DateFormat.ToString(), CultureInfo.CurrentCulture); ItemTransaction st = sml.StockCount(CurrentEnvironment.LoggedUser.HealthFacility, ddlGtin.SelectedValue, ddlItemLot.SelectedValue, qty, CurrentEnvironment.LoggedUser.Id, date); int i = st.Id; // ItemTransaction.Insert(o); if (i > 0) { lblSuccess.Visible = true; lblWarning.Visible = false; lblError.Visible = false; odsTransactionLines.SelectParameters.Clear(); odsTransactionLines.SelectParameters.Add("i", i.ToString()); odsTransactionLines.DataBind(); ClearControls(this); } else { lblSuccess.Visible = false; lblWarning.Visible = false; lblError.Visible = true; } } } catch (Exception ex) { lblSuccess.Visible = false; lblWarning.Visible = false; lblError.Visible = true; } }