/// <summary> /// Row Command capture for gvRegionPriceTrack GridView /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvRegionPriceTrack_RowCommand(object sender, GridViewCommandEventArgs e) { string Issues = string.Empty; try { //Edit, Update, Delete, User string s = String.Empty; CheckBox chk; Label Lbl; TextBox txt; string cname = e.CommandName.ToString(); int RowID = Convert.ToInt32(e.CommandArgument); GridViewRow r = gvRegionPriceTrack.Rows[RowID]; DataRowView rv = (DataRowView)r.DataItem; DateTime BDate = DateTime.Now; string sBDate = BDate.ToString("MM/dd/yyyy"); Lbl = (Label)r.FindControl("lblRegPTID"); int ID = Convert.ToInt32(Lbl.Text); Lbl = (Label)r.FindControl("lblRegPTSpecie"); string Specie = Lbl.Text; Lbl = (Label)r.FindControl("lblRegPTThick"); string Thickness = Lbl.Text; Lbl = (Label)r.FindControl("lblRegPTGrade"); string Grade = Lbl.Text; Lbl = (Label)r.FindControl("lblRegPTRegion"); string Reg = Lbl.Text; Lbl = (Label)r.FindControl("lblRegPTProduct"); string Prod = Lbl.Text; Lbl = (Label)r.FindControl("lblRegPTProdDesc"); string ProdDesc = Lbl.Text; txt = (TextBox)r.FindControl("txtRegPTComment"); string CommentPM = txt.Text; HiddenField hf = (HiddenField)r.FindControl("hfProdID"); string ProdID = hf.Value; //Lbl = (Label)r.FindControl("lblRegPTCommentReg"); //string CommentReg = Lbl.Text; txt = (TextBox)r.FindControl("txtRegPTPrice"); string sPrice = txt.Text; s = txt.Text.Replace("$", ""); s = s.Replace(",", ""); if (s == "") { s = "0"; } double Price = Convert.ToDouble(s); int Mngd = 0; int Tracked = 0; chk = (CheckBox)r.FindControl("chkRegPTManaged"); if (chk.Checked == true) { Tracked = 1; Mngd = 1; } Lbl = (Label)r.FindControl("lblRegPTProdLen"); string Len = Lbl.Text; Lbl = (Label)r.FindControl("lblRegPTProdColor"); string Color = Lbl.Text; Lbl = (Label)r.FindControl("lblRegPTProdSort"); string Sort = Lbl.Text; Lbl = (Label)r.FindControl("lblRegPTProdMilling"); string Milling = Lbl.Text; Lbl = (Label)r.FindControl("lblRegPTProdNoPrint"); string NoPrint = Lbl.Text; //Cells: 0-AppAreaU, 1-GroupUserID, 2-UserGroup, 3-FullUserName, 4-sRightLevel, 5-sBeginDate, 6-sEndDate, 7-btnEditRight/btnDelRight/btnEditUser, 8-UserLastName, 9-UserFirstName, 10-UserMiddleName // 11-EmailAddress, 12-EmpPosition, 13-RightLevel, 14-UserGroupCode, 15-UserGroupID, 16-UserLogin, 17-sActive, 18-sContractor, 19-UserID, 20-EmpID switch (cname) { //case "PriceEdit": // break; //case "CommentEdit": // break; case "Edit1": try { this.divItemEdit.Style["display"] = "block"; this.lblCatDataIDE.Text = ID.ToString(); this.txtProductE.Text = Prod; this.txtProdDescE.Text = ProdDesc; this.ddlIsManagedE.SelectedValue = Mngd.ToString(); this.ddlIsTrackedE.SelectedValue = Tracked.ToString(); } catch (HttpException hex) { this.lblErrorMsg.Text = hex.Message; } try { this.ddlItemColorE.SelectedValue = Color; } catch (Exception e1) { if (Issues.Length > 0) { Issues += Environment.NewLine; } Issues += e1.Message; } try { this.ddlItemGradeE.SelectedValue = Grade; } catch (Exception e2) { if (Issues.Length > 0) { Issues += Environment.NewLine; } Issues += e2.Message; } try { this.ddlItemLengthE.SelectedValue = Len; } catch (Exception e3) { if (Issues.Length > 0) { Issues += Environment.NewLine; } Issues += e3.Message; } try { this.ddlItemMillingE.SelectedValue = Milling; } catch (Exception e4) { if (Issues.Length > 0) { Issues += Environment.NewLine; } Issues += e4.Message; } try { this.ddlItemNoPrintE.SelectedValue = NoPrint; } catch (Exception e5) { if (Issues.Length > 0) { Issues += Environment.NewLine; } Issues += e5.Message; } try { this.ddlItemSortE.SelectedValue = Sort; } catch (Exception e6) { if (Issues.Length > 0) { Issues += Environment.NewLine; } Issues += e6.Message; } try { this.ddlItemSpeciesE.SelectedValue = Specie; } catch (Exception e7) { if (Issues.Length > 0) { Issues += Environment.NewLine; } Issues += e7.Message; } try { this.ddlItemThicknessE.SelectedValue = Thickness; } catch (Exception e8) { if (Issues.Length > 0) { Issues += Environment.NewLine; } Issues += e8.Message; } try { this.txtPriceE.Text = GenUtilities.FormatToMoney(Price); this.txtCommentPmE.Text = CommentPM; this.ddlRegionE.SelectedValue = Reg; } catch (Exception e9) { if (Issues.Length > 0) { Issues += Environment.NewLine; } Issues += e9.Message; } this.txtProductE.Focus(); if (Issues.Length > 0) { lblErrorMsg.Text = Issues; } this.spnAddNewRowBtn.Style["display"] = "none"; this.spnSaveDataBtn.Style["display"] = "inline"; this.spnCancelEditBtn.Style["display"] = "inline"; break; case "Delete1": UpdateItemData(ID, 3, Reg, Prod, ProdID, ProdDesc, Price, Specie, Thickness, Grade, Len, Color, Sort, Milling, NoPrint, Tracked, Mngd, CommentPM); break; case "New1": this.lblCatDataIDE.Text = "0"; this.ddlRegionE.SelectedValue = Reg; if (Mngd == 1) { this.ddlIsManagedE.SelectedValue = "1"; } else { this.ddlIsManagedE.SelectedValue = "0"; } if (Tracked == 1) { this.ddlIsTrackedE.SelectedValue = "1"; } else { this.ddlIsTrackedE.SelectedValue = "0"; } this.txtProductE.Text = Prod; this.txtProdDescE.Text = ProdDesc; this.txtPriceE.Text = sPrice; if (Specie == "") { Specie = "0"; } if (Thickness == "") { Thickness = "0"; } if (Grade == "") { Grade = "0"; } if (Len == "") { Len = "0"; } if (Color == "") { Color = "0"; } if (Sort == "") { Sort = "0"; } if (Milling == "") { Milling = "0"; } if (NoPrint == "") { NoPrint = "0"; } this.ddlItemSpeciesE.SelectedValue = Specie; this.ddlItemThicknessE.SelectedValue = Thickness; this.ddlItemGradeE.SelectedValue = Grade; this.ddlItemLengthE.SelectedValue = Len; this.ddlItemColorE.SelectedValue = Color; this.ddlItemSortE.SelectedValue = Sort; this.ddlItemMillingE.SelectedValue = Milling; this.ddlItemNoPrintE.SelectedValue = NoPrint; this.txtCommentPmE.Text = CommentPM; this.spnAddNewRowBtn.Style["display"] = "none"; this.spnSaveDataBtn.Style["display"] = "inline"; this.btnSaveEdit.Text = "Save"; this.spnCancelEditBtn.Style["display"] = "inline"; this.divItemEdit.Style["display"] = "block"; break; default: break; } // reload data gvRegionPriceTrackLoad(); } catch (Exception ex) { lblErrorMsg.Text = "Error accessing item data: " + ex.Message; } }