/// <summary> /// Add or updates the default process and rate for the item /// </summary> /// <param name="Item">The <c ref="DTO.Item">DTO</c> Item</param> /// <param name="branchId">The Branch Id</param> protected void SaveDefPrcAndRate(ref DTO.Item Item, string branchId) { // if there is no process defined, and no rate is specified // then do nothing! SaveDefPrcAndRate(ref Item, branchId, false); }
/// <summary> /// Add or updates the default process and rate for the item /// </summary> /// <param name="Item">The <see cref="DTO.Item">DTO</see> Item</param> /// <param name="isUpdating">Is updating the record</param> /// <param name="branchId">The branchId</param> protected void SaveDefPrcAndRate(ref DTO.Item Item, string branchId, bool isUpdating) { // not using DAL, because no real work is being done there, might as well skip it! if (!string.IsNullOrEmpty(txtProcess.Text.Trim()) && !string.IsNullOrEmpty(txtDefaultRate.Text.Trim())) { DAL.DALFactory.Instance.DAL_Item.SaveDefPrcAndRate(ref Item, branchId, isUpdating, int.Parse(ddlRateList.SelectedValue)); } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (txtItemName.Text == "") { lblErr.Text = "Please enter item name to save."; return; } int x1 = 1, TotalSubQty = 0; for (int x = 0; x < lstSubItem.Items.Count; x++) { x1 = x + 1; } try { if (rdbinch.Checked) { TotalSubQty = 1; x1 = 1; } if (rdbpanel.Checked) { TotalSubQty = 1; x1 = 1; } if (rdbPcs.Checked) { TotalSubQty = int.Parse(txtItemSubQty.Text.Trim()); } } catch (Exception excp) { lblErr.Text = "Error: Invalid no. of sub items."; return; } if (txtProcess.Text != "") { if (BAL.BALFactory.Instance.BAL_Item.CheckIfProcessCodeExits(txtProcess.Text, Globals.BranchID) != true) { lblErr.Text = "Please select valid process."; txtProcess.Focus(); txtProcess.Attributes.Add("onfocus", "javascript:select();"); return; } } if (TotalSubQty == x1) { Item = SetValue(); Common.Result = BAL.BALFactory.Instance.BAL_Item.UpdateItem(Item); if (Common.Result == "Record Saved") { Item.OldItemName = (string)ViewState["ItemPrevName"]; Common.Result = BAL.BALFactory.Instance.BAL_Item.DeleteSubItem(Item); if (Common.Result == "Record Saved") { if (Item.NoOfItem == "1") { Item.SubItemName = txtItemName.Text; Item.SubItemOrder = "1"; Common.Result = DAL.DALFactory.Instance.DAL_Item.SaveSubItem(Item); if (Common.Result == "Record Saved") { lblMsg.Text = "Item Updated Successfully"; SaveDefPrcAndRate(ref Item, Globals.BranchID, true); RefreshPage(); } } else { int inc = 0; for (int i = 1; i <= lstSubItem.Items.Count; i++) { Item.SubItemName = lstSubItem.Items[inc].Text; Item.SubItemOrder = i.ToString(); Common.Result = DAL.DALFactory.Instance.DAL_Item.SaveSubItem(Item); if (Common.Result != "Record Saved") { break; } inc++; } if (Common.Result == "Record Saved") { lblMsg.Text = PrjClass.UpdateSuccess; SaveDefPrcAndRate(ref Item, Globals.BranchID, true); RefreshPage(); } else { lblErr.Text = Common.Result; } } } } else { lblErr.Text = Common.Result; txtItemCode.Focus(); txtItemCode.Attributes.Add("onfocus", "javascript:select();"); } if (Common.Result == "Record Saved") { Item.OldItemName = (string)ViewState["ItemPrevName"]; Common.Result = BAL.BALFactory.Instance.BAL_Item.UpdateExitingItem(Item); RefreshPage(); } } else { lblErr.Text = "Item List Should be match with Sub Items Quantity"; txtItemSubQty.Focus(); return; } }
protected void btnTemp_Click(object sender, EventArgs e) { DataSet dsMain = new DataSet(); try { itemname = txtItemNameSearch.Text.Split('-'); txtItemNameSearch.Text = itemname[1].Trim(); if (BAL.BALFactory.Instance.Bal_Processmaster.CheckCorrectItem(Globals.BranchID, itemname[1].Trim()) == false) { Session["ReturnMsg"] = "Please enter valid item name."; txtItemNameSearch.Focus(); txtItemNameSearch.Attributes.Add("onfocus", "javascript:select();"); } else { ddlRateList.SelectedIndexChanged -= ddlRateListChange; ddlRateList.SelectedIndex = 0; ddlRateList.SelectedIndexChanged += ddlRateListChange; lblUpdateId.Text = BAL.BALFactory.Instance.Bal_Processmaster.GetItemId(Globals.BranchID, itemname[1].Trim(), itemname[0].Trim()); dsMain = BAL.BALFactory.Instance.Bal_Processmaster.getItem(lblUpdateId.Text, Globals.BranchID); DTO.Item Ob = new DTO.Item(); if (dsMain.Tables[0].Rows.Count > 0) { Ob.ItemName = "" + dsMain.Tables[0].Rows[0]["ItemName"].ToString(); Ob.BranchId = Globals.BranchID; txtItemName.Text = "" + dsMain.Tables[0].Rows[0]["ItemName"].ToString(); txtItemSubQty.Text = "" + dsMain.Tables[0].Rows[0]["NumberOfSubItems"].ToString(); hdntemp.Value = txtItemSubQty.Text; txtItemCode.Text = "" + dsMain.Tables[0].Rows[0]["ItemCode"].ToString(); hdnItemCode.Value = txtItemCode.Text; SetTextbox(); hdntemp.Value = "1"; string unit = dsMain.Tables[0].Rows[0]["Unit"].ToString(); lstSubItem.Items.Clear(); if (dsMain.Tables[1].Rows.Count > 1) { for (int i = 0; i < dsMain.Tables[1].Rows.Count; i++) { lstSubItem.Items.Add(dsMain.Tables[1].Rows[i]["SubItemName"].ToString()); } } if (dsMain.Tables[2].Rows.Count > 0) { txtDefaultRate.Text = "" + dsMain.Tables[2].Rows[0]["ProcessPrice"].ToString(); txtProcess.Text = "" + dsMain.Tables[2].Rows[0]["ProcessCode"].ToString(); } else { txtDefaultRate.Text = ""; txtProcess.Text = ""; } lblSaveOption.Text = "2"; ViewState["ItemPrevName"] = txtItemName.Text; EnableModification(false); EnableModification(true); txtItemName.Focus(); btnSave.Visible = false; //btnCopy.Visible = true; if (unit == "Pcs") { rdbPcs.Checked = true; rdbpanel.Checked = false; rdbinch.Checked = false; } else if (unit == "P") { rdbpanel.Checked = true; rdbinch.Checked = false; rdbPcs.Checked = false; txtItemSubQty.Enabled = false; } else if (unit == "LB") { rdbinch.Checked = true; rdbPcs.Checked = false; rdbpanel.Checked = false; txtItemSubQty.Enabled = false; } if (BAL.BALFactory.Instance.BAL_Item.CheckItemStatus(Ob) == true) { rdbinch.Enabled = false; rdbpanel.Enabled = false; rdbPcs.Enabled = false; btnUpdate.Visible = true; btnDelete.Visible = false; EnableModification(false); txtItemCode.Enabled = true; txtItemCode.Focus(); txtItemCode.Attributes.Add("onfocus", "javascript:select();"); } else { rdbinch.Enabled = true; rdbpanel.Enabled = true; rdbPcs.Enabled = true; btnUpdate.Visible = true; btnDelete.Visible = true; txtItemName.Focus(); txtItemName.Attributes.Add("onfocus", "javascript:select();"); } } else { lblErr.Text += " Could not get details."; lstSubItem.Items.Clear(); } } } catch (Exception ex) { Session["ReturnMsg"] = "Please enter valid item name."; txtItemNameSearch.Focus(); txtItemNameSearch.Attributes.Add("onfocus", "javascript:select();"); } }
protected void grdSearchResult_SelectedIndexChanged(object sender, EventArgs e) { lblUpdateId.Text = grdSearchResult.SelectedRow.Cells[3].Text.Replace(" ", ""); SqlConnection sqlcon = new SqlConnection(PrjClass.sqlConStr); DataSet dsMain = new DataSet(); try { sqlcon.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = sqlcon; cmd.CommandText = "SP_Sel_RecForItemIdUpdate"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@ItemId", lblUpdateId.Text)); cmd.Parameters.Add(new SqlParameter("@BranchId", Globals.BranchID)); SqlDataAdapter sadp = new SqlDataAdapter(); sadp.SelectCommand = cmd; sadp.Fill(dsMain); } catch (Exception excp) { lblErr.Text = "Error : " + excp.Message; } finally { sqlcon.Close(); sqlcon = null; } if (dsMain.Tables[0].Rows.Count > 0) { DTO.Item Ob = new DTO.Item(); Ob.ItemName = "" + dsMain.Tables[0].Rows[0]["ItemName"].ToString(); Ob.BranchId = Globals.BranchID; txtItemName.Text = "" + dsMain.Tables[0].Rows[0]["ItemName"].ToString(); txtItemSubQty.Text = "" + dsMain.Tables[0].Rows[0]["NumberOfSubItems"].ToString(); hdntemp.Value = txtItemSubQty.Text; txtItemCode.Text = "" + dsMain.Tables[0].Rows[0]["ItemCode"].ToString(); hdnItemCode.Value = txtItemCode.Text; string unit = "" + dsMain.Tables[0].Rows[0]["Unit"].ToString(); SetTextbox(); hdntemp.Value = "1"; lstSubItem.Items.Clear(); if (dsMain.Tables[1].Rows.Count > 1) { for (int i = 0; i < dsMain.Tables[1].Rows.Count; i++) { lstSubItem.Items.Add(dsMain.Tables[1].Rows[i]["SubItemName"].ToString()); } } if (dsMain.Tables[2].Rows.Count > 0) { txtDefaultRate.Text = "" + dsMain.Tables[2].Rows[0]["ProcessPrice"].ToString(); txtProcess.Text = "" + dsMain.Tables[2].Rows[0]["ProcessCode"].ToString(); } else { txtDefaultRate.Text = ""; txtProcess.Text = ""; } lblSaveOption.Text = "2"; ViewState["ItemPrevName"] = txtItemName.Text; EnableModification(false); EnableModification(true); txtItemName.Focus(); btnSave.Visible = false; // btnCopy.Visible = true; if (unit == "Pcs") { rdbPcs.Checked = true; rdbpanel.Checked = false; rdbinch.Checked = false; } else if (unit == "P") { rdbpanel.Checked = true; rdbinch.Checked = false; rdbPcs.Checked = false; txtItemSubQty.Enabled = false; } else if (unit == "LB") { rdbinch.Checked = true; rdbPcs.Checked = false; rdbpanel.Checked = false; txtItemSubQty.Enabled = false; } if (BAL.BALFactory.Instance.BAL_Item.CheckItemStatus(Ob) == true) { rdbinch.Enabled = false; rdbpanel.Enabled = false; rdbPcs.Enabled = false; btnUpdate.Visible = true; btnDelete.Visible = false; EnableModification(false); txtItemCode.Enabled = true; txtItemCode.Focus(); txtItemCode.Attributes.Add("onfocus", "javascript:select();"); } else { rdbinch.Enabled = true; rdbpanel.Enabled = true; rdbPcs.Enabled = true; btnUpdate.Visible = true; btnDelete.Visible = true; txtItemName.Focus(); txtItemName.Attributes.Add("onfocus", "javascript:select();"); } } else { lblErr.Text += " Could not get details."; lstSubItem.Items.Clear(); } }