public bool ExibirBotao(ASPxGridView grid, int visibleIndex) { object row = grid.GetRow(visibleIndex); string arquivo = ""; if (visibleIndex != 0) { arquivo = grid.GetRowValues(visibleIndex, "ARQUIVO").ToString(); } if (string.IsNullOrEmpty(arquivo)) { return false; } else { return true; } }
protected void GridBookingProcessView_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridViewCustomButtonCallbackEventArgs e) { if (e.ButtonID == "ButtonBookingDetails") { ASPxGridView grid = sender as ASPxGridView; List <BookingProcessViewModel> list = (List <BookingProcessViewModel>)grid.DataSource; //Todo: Ivane da li trebas ovaj code ?? int index = e.VisibleIndex; string id = grid.GetRowValues(index, "Id").ToString(); /* string country = (string) grid.GetRowValues(index, "Country") ?? string.Empty; * string placename = grid.GetRowValues(index, "PlaceName").ToString(); * string firstname = grid.GetRowValues(index, "FirstName").ToString(); * string lastname = grid.GetRowValues(index, "LastName").ToString(); * * var item = list.Find(p => p.Id == id); * * var bookingitems = item.BookingProcessItemList;*/ // Response.Redirect("~/AspxArea/PriceList/Forms/PurchasePriceForm.aspx?sc=" + sitecode + "&oc=" + unitcode); ASPxWebControl.RedirectOnCallback(VirtualPathUtility.ToAbsolute("~/AspxArea/Booking/Forms/BookingProcessDetailsProView.aspx?id=" + id)); } }
private string FncGenerarDataGps() { string xresultado = string.Empty; try { if (this.PivotGrid.RowCount > -1) { ASPxGridView xgrid = new ASPxGridView(); xgrid.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords; xgrid.DataSource = this.PivotGrid.CreateDrillDownDataSource(); xgrid.DataBind(); if (xgrid.VisibleRowCount > 0) { List <LMap> lmapas = new List <LMap>(); for (int i = 0; i < xgrid.VisibleRowCount; i++) { LMap lmapa = new LMap(); lmapa.UTM_Latitud = Convert.ToString(xgrid.GetRowValues(i, "GpsLatitud")); lmapa.UTM_Longitud = Convert.ToString(xgrid.GetRowValues(i, "GpsLongitud")); lmapa.Descripcion = "Cuenca:" + Convert.ToString(xgrid.GetRowValues(i, "Cuenca_DSC")) + "<br/>" + "Sub-Cuenca:" + Convert.ToString(xgrid.GetRowValues(i, "SubCuencaRio_DSC")) + "<br/>" + "Punto Monitoreo:" + Convert.ToString(xgrid.GetRowValues(i, "PuntoMonitoreo_DSC")) + "<br/>" + "Fecha:" + Convert.ToString(xgrid.GetRowValues(i, "FechaHoraInicial")) + "<br/>" + "Caudal:" + Convert.ToString(xgrid.GetRowValues(i, "Caudal")); lmapas.Add(lmapa); } if (lmapas.Count > 0) { xresultado = JsonConvert.SerializeObject(lmapas); } } } } catch (Exception ex) { xresultado = ex.Message; xresultado = string.Empty; } return(xresultado); }
protected void GridTouristUnitView_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridViewCustomButtonCallbackEventArgs e) { ASPxGridView grid = sender as ASPxGridView; int index = e.VisibleIndex; if (e.ButtonID == "ButtonPriceList") { string unitcode = grid.GetRowValues(index, "UnitCode").ToString(); string sitecode = grid.GetRowValues(index, "SiteCode").ToString(); // Response.Redirect("~/AspxArea/PriceList/Forms/PurchasePriceForm.aspx?sc=" + sitecode + "&oc=" + unitcode); ASPxWebControl.RedirectOnCallback(VirtualPathUtility.ToAbsolute("~/AspxArea/PriceList/Forms/PurchasePriceForm.aspx?sc=" + sitecode + "&uc=" + unitcode)); } else if (e.ButtonID == "ButtonUnit") { string unitcode = grid.GetRowValues(index, "UnitCode").ToString(); string sitecode = grid.GetRowValues(index, "SiteCode").ToString(); string tourOperatorCode = grid.GetRowValues(index, "TourOperatorCode").ToString(); string id = grid.GetRowValues(index, "id").ToString(); ASPxWebControl.RedirectOnCallback(VirtualPathUtility.ToAbsolute("~/AspxArea/MasterData/Forms/UnitForm.aspx?id=" + id + "&sc=" + sitecode + "&uc=" + unitcode + "&to=" + tourOperatorCode + "&plt=" + "1")); } }
protected void gdvPartyAttribute_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) { ASPxGridView gdv = (ASPxGridView)sender; ITransaction tx = iSabayaContext.PersistenceSession.BeginTransaction(); JsonObjectCollection objs = new JsonObjectCollection(); bool isSetNewFoucused = false; bool isCommit = true; long attributeID = 0; string msg = ""; try { string[] parameters = e.Parameters.Split(';'); switch (parameters[0]) { case KEY_EDIT: attributeID = this.CreatePartyAttribute(long.Parse(parameters[1])); isSetNewFoucused = true; break; case KEY_EXPIRE: int index = Int32.Parse(parameters[1]); if (OwnerID == 0) { gdv.DataBind(); PartyAttribute attribute = (PartyAttribute)gdv.GetRow(index); ICategorizedTemporalList <PartyAttribute> attributes = PartyAttributes; for (int i = 0; i < attributes.Count; i++) { if (attributes[i].AttributeKey == attribute.AttributeKey) { attributes.Remove(attributes[i]); break; } } } else { attributeID = (int)gdv.GetRowValues(index, gdv.KeyFieldName); this.ExpirePartyAttribute(attributeID); } break; // when owner id = 0 only case "clear": if (OwnerID == 0) { PartyAttributes.Clear(); } break; default: isCommit = false; break; } if (isCommit) { tx.Commit(); } gdv.DataBind(); if (attributeID > 0 && isSetNewFoucused) { for (int i = gdv.VisibleRowCount - 1; i >= gdv.VisibleStartIndex; i--) { if ((int)gdv.GetRowValues(i, gdv.KeyFieldName) == attributeID) { gdv.FocusedRowIndex = i; break; } } } else { gdv.FocusedRowIndex = 0; } } catch (Exception ex) { if (isCommit) { tx.Rollback(); } while (ex != null) { msg = ex.Message + "\n" + msg; ex = ex.InnerException; } gdv.DataBind(); } objs.Add(new JsonNumericValue("AttributeID", attributeID)); objs.Add(new JsonStringValue("Message", msg)); gdv.JSProperties[KEY_CP_RESULT] = objs.ToString(); }
protected void ASPxGridView1_CustomButtonInitialize(object sender, ASPxGridViewCustomButtonEventArgs e) { ASPxGridView grid = (ASPxGridView)sender; string flag = grid.GetRowValues(e.VisibleIndex, "HANDLE_FLAG") as string; if (flag == "N") { if (e.ButtonID == "takeSure") { e.Visible = DefaultBoolean.False; } if (e.ButtonID == "SURE1") { e.Visible = DefaultBoolean.False; } if (e.ButtonID == "SURE2") { e.Visible = DefaultBoolean.False; } } if (flag == "1") { if (e.ButtonID == "cancelSure") { e.Visible = DefaultBoolean.False; } if (e.ButtonID == "SURE1") { e.Visible = DefaultBoolean.False; } if (e.ButtonID == "SURE2") { e.Visible = DefaultBoolean.False; } } if (flag == "2") { if (e.ButtonID == "takeSure") { e.Visible = DefaultBoolean.False; } if (e.ButtonID == "cancelSure") { e.Visible = DefaultBoolean.False; } if (e.ButtonID == "SURE1") { e.Enabled = false; } if (e.ButtonID == "SURE2") { e.Visible = DefaultBoolean.False; } } if (flag == "3") { if (e.ButtonID == "takeSure") { e.Visible = DefaultBoolean.False; } if (e.ButtonID == "cancelSure") { e.Visible = DefaultBoolean.False; } if (e.ButtonID == "SURE1") { e.Visible = DefaultBoolean.False; } if (e.ButtonID == "SURE2") { e.Enabled = false; } } }
public void ASPxGridView1_CustomButtonInitialize(object sender, ASPxGridViewCustomButtonEventArgs e) { ASPxGridView grid = (ASPxGridView)sender; string run_flag = grid.GetRowValues(e.VisibleIndex, "RUN_FLAG") as string; string item_flag = grid.GetRowValues(e.VisibleIndex, "ITEM_FLAG") as string; string third_flag = grid.GetRowValues(e.VisibleIndex, "THIRD_FLAG") as string; string confirm_flag = grid.GetRowValues(e.VisibleIndex, "CONFIRM_FLAG") as string; string plancode = grid.GetRowValues(e.VisibleIndex, "PLAN_CODE") as string; string sql1 = "select nvl(online_qty,0) from data_plan where plan_code='" + plancode + "' and rownum=1"; DataTable dt1 = dc.GetTable(sql1); string isonline = "0"; if (dt1.Rows.Count > 0) { isonline = dt1.Rows[0][0].ToString(); } switch (e.ButtonID) { case "Confirm": if (e.CellType == GridViewTableCommandCellType.Filter) { break; } if (run_flag == "Y") { e.Enabled = false; } if (run_flag == "N") { e.Enabled = true; } else { e.Enabled = false; } break; case "Cancel": //if (item_flag == "Y" && confirm_flag == "Y" && run_flag == "Y") if (e.CellType == GridViewTableCommandCellType.Filter) { break; } if (run_flag == "Y" && isonline == "0") { e.Enabled = true; } if (isonline != "0") { e.Enabled = false; } if (run_flag == "N") { e.Enabled = false; } break; case "Unlock": string sql = "select nvl(flag,'Y') from atpujhb_tmp where jhmc='" + plancode + "'"; if (dc.GetValue(sql) == "Y" || dc.GetTable(sql).Rows.Count == 0) { e.Visible = DevExpress.Utils.DefaultBoolean.False; } break; } }
public void ASPxGridView1_CustomButtonInitialize(object sender, ASPxGridViewCustomButtonEventArgs e) { ASPxGridView grid = (ASPxGridView)sender; if (grid.GetRowValues(e.VisibleIndex, "GHTM") == null) { return; } string lsh = grid.GetRowValues(e.VisibleIndex, "GHTM") as string; string sql = "select count(1) from qad_bkfl where lsh='" + lsh + "'"; string sl1 = dc.GetValue(sql); string sql2 = "select count(1) from dp_rkwcb where ghtm='" + lsh + "'"; string sl2 = dc.GetValue(sql2); string sql3 = "select count(1) from qad_bkflrecord where lsh1='" + lsh + "'"; string sl3 = dc.GetValue(sql3); int isl1 = Convert.ToInt32(sl1); int isl2 = Convert.ToInt32(sl2); int isl3 = Convert.ToInt32(sl3); //int isl1 = 0; //int isl2 = 0; //int isl3 = 0; switch (e.ButtonID) { case "Offset1": if (e.CellType == GridViewTableCommandCellType.Filter) { break; } if (isl1 > 0) { e.Enabled = false; e.Visible = DefaultBoolean.False; } else if (isl2 > 0) { if (isl3 == 0) { e.Enabled = true; e.Visible = DefaultBoolean.True; } else { e.Visible = DefaultBoolean.False; } } break; case "Offset2": if (e.CellType == GridViewTableCommandCellType.Filter) { break; } if (isl1 > 0) { e.Enabled = false; e.Visible = DefaultBoolean.True; } else { e.Visible = DefaultBoolean.False; } break; case "Offset3": if (e.CellType == GridViewTableCommandCellType.Filter) { break; } if (isl1 > 0) { e.Enabled = false; e.Visible = DefaultBoolean.False; } else if (isl2 > 0) { if (isl3 == 0) { e.Enabled = false; e.Visible = DefaultBoolean.False; } else { e.Enabled = true; e.Visible = DefaultBoolean.True; } } break; } }
private string GetSelectedRowValueRadioButton(string coluna, ASPxGridView Grid) { string valor = ""; string[] valueToGet = { coluna }; for (int i = 0; i < Grid.VisibleRowCount; i++) { if (Grid.Selection.IsRowSelected(i)) { valor = Grid.GetRowValues(i, valueToGet).ToString(); break; } } return valor; }
private List<object> GetSelectedRowValues(string aColumnName, ASPxGridView Grid) { List<object> values = new List<object>(); string[] valueToGet = { aColumnName }; for (int i = 0; i < Grid.VisibleRowCount; i++) { if (Grid.Selection.IsRowSelected(i)) { values.Add(Grid.GetRowValues(i, valueToGet)); } } return values; }
public void gridCallBackOption(ASPxGridView grid, string param, string KeyFieldName, SqlDataSource ds) { try { HttpCookie myCookie = Request.Cookies[CU.getuserid().ToString()]; switch (param) { case "isShowFiltertrue": grid.Settings.ShowFilterBar = GridViewStatusBarMode.Visible; if (myCookie != null) myCookie["GroupFilter"] = "true"; break; case "isShowFilterfalse": grid.Settings.ShowFilterBar = GridViewStatusBarMode.Hidden; if (myCookie != null) myCookie["GroupFilter"] = "false"; break; case "isShowHScrolltrue": grid.Settings.HorizontalScrollBarMode = DevExpress.Web.ASPxClasses.ScrollBarMode.Visible; if (myCookie != null) myCookie["HScroll"] = "true"; break; case "isShowHScrollfalse": grid.Settings.HorizontalScrollBarMode = DevExpress.Web.ASPxClasses.ScrollBarMode.Hidden; if (myCookie != null) myCookie["HScroll"] = "false"; break; case "isShowHypColtrue": grid.AccessibilityCompliant = true; if (myCookie != null) myCookie["HypCol"] = "true"; break; case "isShowHypColfalse": grid.AccessibilityCompliant = false; if (myCookie != null) myCookie["HypCol"] = "false"; break; case "isShowGrouptrue": grid.Settings.ShowGroupPanel = true; if (myCookie != null) myCookie["Grouptrue"] = "true"; break; case "isShowGroupfalse": grid.Settings.ShowGroupPanel = false; if (myCookie != null) myCookie["Grouptrue"] = "false"; break; } List<object> listKeyValueOK = new List<object>(); if (param.IndexOf("focus") >= 0) { int id = 0; Int32.TryParse(param.Replace("focus", ""), out id); if (id > 0) grid.FocusedRowIndex = grid.FindVisibleIndexByKeyValue(param.Replace("focus", "")); } else if (param.IndexOf("action") >= 0) { int action = int.Parse(param.Replace("action", "")); List<object> listkeyvalue = grid.GetSelectedFieldValues(grid.KeyFieldName); SiAuto.Main.LogColored(System.Drawing.Color.Purple, grid.KeyFieldName + "Số dòng :" + listkeyvalue.Count); if (listkeyvalue.Count > 0) { for (int i = 0; i < listkeyvalue.Count; i++) { SiAuto.Main.LogColored(System.Drawing.Color.Purple, "key so :" + i.ToString() + "----" + listkeyvalue[i]); string currentCode = "isApproved=" + action + " AND " + grid.KeyFieldName + "=" + listkeyvalue[i]; bool check = EU.CheckByModuleD(globalModuleID, currentCode); if (check == true) { var values = new Dictionary<string, object> { {"isApproved",action}, {grid.KeyFieldName,listkeyvalue[i]} }; EU.updateTblScript(globalModuleID, values); listKeyValueOK.Add(listkeyvalue[i]); } } if (listKeyValueOK.Count > 0) { if (action == 1) { WorkFlowManager.BuildTaskByWhenExecute(globalModuleID, "APPROVED", string.Join(";", listKeyValueOK)); UserUtils.Log(CU.getLoginID(), globalModuleID, -1, string.Join(";", listKeyValueOK), "", "Duyệt thành công !", "APPROVED"); } else { WorkFlowManager.BuildTaskByWhenExecute(globalModuleID, "NOTAPPROVED", string.Join(";", listKeyValueOK)); UserUtils.Log(CU.getLoginID(), globalModuleID, -1, string.Join(";", listKeyValueOK), "", "Bỏ duyệt thành công !", "NOTAPPROVED"); } listKeyValueOK.Clear(); } } else { object currentFocused = grid.GetRowValues(grid.FocusedRowIndex, grid.KeyFieldName); string currentCode = "isApproved=" + action + " AND " + grid.KeyFieldName + "=" + currentFocused.ToString(); bool check = EU.CheckByModuleD(globalModuleID, currentCode); if (check == true) { if (currentFocused != null) { var values = new Dictionary<string, object>{ {"isApproved",action}, {grid.KeyFieldName,currentFocused} }; EU.updateTblScript(globalModuleID, values); if (action == 1) { SiAuto.Main.LogColored(Color.Green, "Chuan bi workflow APPROVED"); WorkFlowManager.BuildTaskByWhenExecute(globalModuleID, "APPROVED", currentFocused.ToString()); SiAuto.Main.LogColored(Color.Green, "End workflow APPROVED"); SiAuto.Main.LogColored(Color.Green, "ghi vao tray - bảng SY_audit_trail APPROVED"); //UserUtils.Log(CU.getLoginID(), globalModuleID, -1, currentFocused.ToString(), "", "Duyệt thành công !", "APPROVED"); SiAuto.Main.LogColored(Color.Green, "end tray "); } else { SiAuto.Main.LogColored(Color.Green, "Chuan bi workflow NOTAPPROVED"); WorkFlowManager.BuildTaskByWhenExecute(globalModuleID, "NOTAPPROVED", currentFocused.ToString()); SiAuto.Main.LogColored(Color.Green, "End workflow NOTAPPROVED"); SiAuto.Main.LogColored(Color.Green, "ghi vao tray - bảng SY_audit_trail NOTAPPROVED"); //UserUtils.Log(CU.getLoginID(), globalModuleID, -1, currentFocused.ToString(), "", "Bỏ duyệt thành công !", "NOTAPPROVED"); SiAuto.Main.LogColored(Color.Green, "end tray NOTAPPROVED"); } } } } UserUtils.Log(CU.getLoginID(), globalModuleID, -1, -1, listkeyvalue.ToString(), "", "APPROVED :" + action); } else if (param.IndexOf("delselect") >= 0) { List<object> listid = grid.GetSelectedFieldValues(new string[] { grid.KeyFieldName }); if (listid.Count > 0) { for (int i = 0; i < listid.Count; i++) { SiAuto.Main.LogColored(System.Drawing.Color.Purple, "key so :" + i.ToString() + "----" + listid[i]); string currentCode = "isDeleted=1 AND " + grid.KeyFieldName + "=" + listid[i]; bool check = EU.CheckByModuleD(globalModuleID, currentCode); if (check == true) { string rowDeleted = EU.deleteMultiTblScript(globalModuleID, grid.KeyFieldName, string.Join(",", listid)); listKeyValueOK.Add(listid[i]); } } if (listKeyValueOK.Count > 0) { WorkFlowManager.BuildTaskByWhenExecute(globalModuleID, "DELETED", string.Join(";", listKeyValueOK)); listKeyValueOK.Clear(); } } else { object currentFocused = grid.GetRowValues(grid.FocusedRowIndex, grid.KeyFieldName); if (currentFocused != null) { string currentCode = "isDeleted=1 AND " + grid.KeyFieldName + "=" + currentFocused.ToString(); bool check = EU.CheckByModuleD(globalModuleID, currentCode); if (check == true) { string rowDeleted = EU.deleteMultiTblScript(globalModuleID, grid.KeyFieldName, string.Join(",", currentFocused.ToString())); if (int.Parse(rowDeleted) > 0) { SiAuto.Main.LogColored(Color.Green, "Chuan bi workflow DELETED"); WorkFlowManager.BuildTaskByWhenExecute(globalModuleID, "DELETED", currentFocused.ToString()); SiAuto.Main.LogColored(Color.Green, "End workflow DELETED"); SiAuto.Main.LogColored(Color.Green, "ghi vao tray - bảng SY_audit_trail DELETED"); UserUtils.Log(CU.getLoginID(), globalModuleID, -1, int.Parse(currentFocused.ToString()), "", "Xóa thành công !", "DELETED"); SiAuto.Main.LogColored(Color.Green, "end tray DELETED"); } } } } } else if (param.IndexOf("RestoreSelect") >= 0) { List<object> listid = grid.GetSelectedFieldValues(new string[] { grid.KeyFieldName }); if (listid.Count > 0) { for (int i = 0; i < listid.Count; i++) { SiAuto.Main.LogColored(System.Drawing.Color.Purple, "key so :" + i.ToString() + "----" + listid[i]); string currentCode = "isDeleted=0 AND " + grid.KeyFieldName + "=" + listid[i]; bool check = EU.CheckByModuleD(globalModuleID, currentCode); if (check == true) { string rowDeleted = EU.restoreMultiTblScript(globalModuleID, grid.KeyFieldName, string.Join(",", listid)); listKeyValueOK.Add(listid[i]); } } if (listKeyValueOK.Count > 0) { WorkFlowManager.BuildTaskByWhenExecute(globalModuleID, "RESTORED", string.Join(";", listKeyValueOK)); listKeyValueOK.Clear(); } } else { object currentFocused = grid.GetRowValues(grid.FocusedRowIndex, grid.KeyFieldName); if (currentFocused != null) { string currentCode = "isDeleted=0 AND " + grid.KeyFieldName + "=" + currentFocused.ToString(); bool check = EU.CheckByModuleD(globalModuleID, currentCode); if (check == true) { string rowDeleted = EU.restoreMultiTblScript(globalModuleID, grid.KeyFieldName, string.Join(",", currentFocused.ToString())); if (int.Parse(rowDeleted) > 0) { SiAuto.Main.LogColored(Color.Green, "Chuan bi workflow RESTORED"); WorkFlowManager.BuildTaskByWhenExecute(globalModuleID, "RESTORED", currentFocused.ToString()); SiAuto.Main.LogColored(Color.Green, "End workflow RESTORED"); SiAuto.Main.LogColored(Color.Green, "ghi vao tray - bảng SY_audit_trail RESTORED"); UserUtils.Log(CU.getLoginID(), globalModuleID, -1, int.Parse(currentFocused.ToString()), "", "Phục hồi thành công !", "RESTORED"); SiAuto.Main.LogColored(Color.Green, "end tray RESTORED"); } } } } } grid.DataBind(); if (myCookie != null) Response.Cookies.Set(myCookie); } catch (Exception ex) { throw new Exception(ex.Message); } }
int GetGridViewKeyByVisibleIndex(ASPxGridView gridView, int visibleIndex) { return((int)gridView.GetRowValues(visibleIndex, gridView.KeyFieldName)); }
private List<object> GetSelectRowValueRadioNovo(string coluna1, string coluna2, string coluna3, string coluna4, string coluna5, ASPxGridView Grid) { List<object> matrix = new List<object>(); // List<object> values = new List<object>(); string[] keyValueToGet = { coluna1 }; string[] valueToGet = { coluna2 }; string[] colunaAUX = { coluna3 }; string[] COLUNA4 = { coluna4 }; string[] COLUNA5 = { coluna5 }; for (int i = 0; i < Grid.VisibleRowCount; i++) { if (Grid.Selection.IsRowSelected(i)) { List<object> values = new List<object>(); values.Add(Grid.GetRowValues(i, keyValueToGet)); values.Add(Grid.GetRowValues(i, valueToGet)); values.Add(Grid.GetRowValues(i, colunaAUX)); values.Add(Grid.GetRowValues(i, COLUNA4)); values.Add(Grid.GetRowValues(i, COLUNA5)); matrix.Add(values); } } return matrix; }
protected void gridEmployees_CustomCallback(object source, ASPxGridViewCustomCallbackEventArgs e) { string param = e.Parameters.ToString(); ASPxGridView gdv = source as ASPxGridView; gdv.JSProperties[JSPROPERTY_CALLBACK_TYPE] = param; switch (param) { case GRID_INVERSE: if (gdv.VisibleRowCount > 0) { for (int i = 0; i < gdv.VisibleRowCount; i++) { gdv.Selection.SetSelection(i, !gdv.Selection.IsRowSelected(i)); } } break; case GRID_BINDING: gdv.DataBind(); break; case GRID_SELECT_BY_VALUE: if (gdv.VisibleRowCount > 0 && bteEmployees.Text.Length > 0) { DataRow dr; if (multiSelection) { string[] employeesNos = bteEmployees.Text.Split(','); if (employeesNos.Length > 0) { bool isContain; StringBuilder accounts = new StringBuilder(); StringBuilder selectedText = new StringBuilder(); StringBuilder employeeNos = new StringBuilder(); for (int i = 0; i < gdv.VisibleRowCount; i++) { dr = gdv.GetDataRow(i); isContain = employeesNos.Contains <string>(dr[FIELDNAME_EMPLOYEENO].ToString()); gdv.Selection.SetSelection(i, isContain); if (isContain) { accounts.AppendFormat(",{0}", dr[FIELDNAME_ACCOUNTID]); employeeNos.AppendFormat(",{0}", dr[FIELDNAME_EMPLOYEENO]); selectedText.AppendFormat("<br>{0} - {1} - {2}", dr[FIELDNAME_DIVISIONCODE], dr[FIELDNAME_EMPLOYEENO], dr[FIELDNAME_EMPLOYEENAME]); } } if (accounts.Length > 0) { //gdv.JSProperties[JSPROPERTY_LBL_SELECTED] = TEXT_EMPLOYEES; gdv.JSProperties[JSPROPERTY_TEXT_POPUP_SELECTED] = selectedText.ToString(); gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID] = accounts.ToString().Substring(1); gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = employeeNos.ToString().Substring(1); return; } } } else { for (int i = 0; i < gdv.VisibleRowCount; i++) { dr = gdv.GetDataRow(i); gdv.Selection.SetSelection(i, bteEmployees.Text == dr[FIELDNAME_EMPLOYEENO].ToString()); if (gdv.Selection.IsRowSelected(i)) { gdv.JSProperties[JSPROPERTY_LBL_SELECTED] = dr[FIELDNAME_EMPLOYEENAME]; gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID] = dr[FIELDNAME_ACCOUNTID]; gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = dr[FIELDNAME_EMPLOYEENO]; return; } } } } gdv.Selection.UnselectAll(); gdv.JSProperties[JSPROPERTY_LBL_SELECTED] = ""; gdv.JSProperties[JSPROPERTY_TEXT_POPUP_SELECTED] = ""; gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID] = ""; gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = ""; break; case GRID_SELECTED: if (gdv.VisibleRowCount > 0) { if (multiSelection) { StringBuilder accounts = new StringBuilder(); StringBuilder selectedText = new StringBuilder(); StringBuilder employeeNos = new StringBuilder(); List <object> selectedList = gdv.GetSelectedFieldValues(FIELDNAME_ACCOUNTID, FIELDNAME_DIVISIONCODE , FIELDNAME_EMPLOYEENO, FIELDNAME_EMPLOYEENAME); foreach (object obj in selectedList) { object[] data = obj as object[]; accounts.AppendFormat(",{0}", data[0]); employeeNos.AppendFormat(",{0}", data[2]); selectedText.AppendFormat("<br>{0} - {1} - {2}", data[1], data[2], data[3]); } if (accounts.Length > 0) { //gdv.JSProperties[JSPROPERTY_LBL_SELECTED] = TEXT_EMPLOYEES; gdv.JSProperties[JSPROPERTY_TEXT_POPUP_SELECTED] = selectedText.ToString(); gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID] = accounts.ToString().Substring(1); gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = employeeNos.ToString().Substring(1); } else { //gdv.JSProperties[JSPROPERTY_LBL_SELECTED] = ""; gdv.JSProperties[JSPROPERTY_TEXT_POPUP_SELECTED] = ""; gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID] = ""; gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = ""; } } else { int index = Int32.Parse(hddEmployeesSelected[HDDKEY_SELECTED_INDEX].ToString()); object[] data = gdv.GetRowValues(index, FIELDNAME_ACCOUNTID, FIELDNAME_EMPLOYEENO , FIELDNAME_EMPLOYEENAME) as object[]; gdv.JSProperties[JSPROPERTY_SELECTED_ACCOUNTID] = data[0]; gdv.JSProperties[JSPROPERTY_SELECTED_EMPLOYEENO] = data[1]; gdv.JSProperties[JSPROPERTY_LBL_SELECTED] = data[2]; gdv.Selection.UnselectAll(); gdv.Selection.SetSelection(index, true); } } break; case GRID_UNDO_SELECTED: gdv.Selection.UnselectAll(); if (!hddEmployeesSelected.Contains(HDDKEY_EMPLOYEES_SELECTED) || String.IsNullOrEmpty(hddEmployeesSelected[HDDKEY_EMPLOYEES_SELECTED].ToString())) { return; } string[] keys = hddEmployeesSelected[HDDKEY_EMPLOYEES_SELECTED].ToString().Split(','); foreach (string key in keys) { gdv.Selection.SetSelectionByKey(Int32.Parse(key), true); } break; default: break; } }
/// <summary> /// this event is not being used, we are using client side asynchronous callbacks and webmethod get_secure_url so we can open page in new window /// custom command buttons vierw/edit/delete (maybe?) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void dxgridOrders_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomButtonCallbackEventArgs e) { ASPxGridView _grid = (ASPxGridView)sender; //get order number off grid //string[] _fields = { "OrderNumber", "OrderID" }; //pass order no, id as encryped data string _orderno = wwi_security.EncryptString(_grid.GetRowValues(e.VisibleIndex, "OrderNumber").ToString(), "publiship"); string _orderid = wwi_security.EncryptString(_grid.GetRowValues(e.VisibleIndex, "OrderID").ToString(), "publiship"); //track requesting page so we can return to it string _req = this.dxhfOrder.Get("req").ToString(); //populated on page load //wwi_security.EncryptString("Search", "publiship"); //page to redirect build as required string _page = ""; switch (e.ButtonID.ToString()) { case "cmdView": { //send orderid and orderno as related tables are linked by orderno not orderid _page = string.Format("../shipment_orders/order.aspx?mode={0}&pid={1}&req={2}&pno={3}", "ReadOnly", _orderid, _req, _orderno); DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(_page); //Response.Redirect(_page); break; } case "cmdEdit": { //send orderid and orderno as related tables are linked by orderno not orderid _page = string.Format("../shipment_orders/order.aspx?mode={0}&pid={1}&req={2}&pno={3}", "Edit", _orderid, _req, _orderno); DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(_page); //Response.Redirect(_page); break; } case "cmdViewFilter": //deprecated we no longer use seperate order_view.aspx so just use cmdView { _page = string.Format("../shipment_orders/order_view.aspx?mode={0}&pid={1}&req={2}", "ReadOnly", _orderid, _req); DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(_page); //Response.Redirect(_page); break; } case "cmdEditFilter": //deprecated { _page = string.Format("../shipment_orders/order_edit.aspx?mode={0}&pid={1}&req={2}", "Edit", _orderid, _req); DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(_page); //Response.Redirect(_page); break; } case "cmdOrderSheet": //order sheet { _page = string.Format("../shipment_orders/order_sheet.aspx?pno={0}", _orderno); //DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(_page); //Response.Redirect(_page); //**** this code does not work //string _err = itextsharp_out.advance_labels(120600005); //_page = string.Format("~/Order_View.aspx?pno={0}", _orderno); //DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(_page); //Response.Redirect(_page); //**** //string _err = itextsharp_out.order_sheet(wwi_func.vint(_orderno)); //if (_err != "") { // this.dxlblErr.Text = _err; // this.dxpnlErr.Visible = true; } break; } case "cmdTemplate": //make template out of selected order { _page = string.Format("../system_templates/order_template.aspx?pid={0}&mode={1}", _orderid, "Insert"); DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(_page); //Response.Redirect(_page); break; } case "cmdClone": //make identical copy of selected order { _page = string.Format("../shipment_orders/clone_order.aspx?pid={0}&pno={1}", _orderid, _orderno); DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(_page); //Response.Redirect(_page); break; } default: { break; } }//end switch }
//end databound /// <summary> /// called from custom command buttons in gridview /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grid_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e) { if (e.ButtonID != "cmdRemove") { return; } string[] _f = new string[] { "DateOrderReceived", "Payee", "DeliveryAddress", "DestinationCountry", "Titles", "Cartons", "Fao" }; //user id Int32 _user = Session["user"] != null ? (Int32)((UserClass)Page.Session["user"]).UserId : 0; //get rows values from grid ASPxGridView _g = (ASPxGridView)sender; object _id = _g.GetRowValues(e.VisibleIndex, _g.KeyFieldName); object _rw = _g.GetRowValues(e.VisibleIndex, _f); //convert object to ienumerable so we can step through values IEnumerable _enum = wwi_func.get_object_to_ienum(_rw); if (_id != null && _user != 0) { Int32 _cid = (Int32)((UserClass)Page.Session["user"]).CompanyId; string _uname = (string)((UserClass)Page.Session["user"]).UserName; //for testing //_cid = 99; // //publiship users can just update the order, clients must send a request for cancellation if (_cid == -1) { //log cancellation int _updated = new Update(PublishipAdvanceOrderTable.Schema) .Set(PublishipAdvanceOrderTable.Columns.CancelDate).EqualTo(DateTime.Now.ToShortDateString()) .Set(PublishipAdvanceOrderTable.Columns.CancelledByID).EqualTo(_user) .Set(PublishipAdvanceOrderTable.Columns.OrderCancelled).EqualTo(true) .Where(PublishipAdvanceOrderTable.Columns.OrderID).IsEqualTo(_id).Execute(); //confirm cancellation to client and publiship if (_updated > 0) { //string _test = return_html_content(_enum, _f); send_advance_email(_id.ToString(), "Order Ref. " + _id + " has been cancelled", return_html_content(_enum, _f)); } } else { //log request int _updated = new Update(PublishipAdvanceOrderTable.Schema) .Set(PublishipAdvanceOrderTable.Columns.CancelRequestRcd).EqualTo(DateTime.Now.ToShortDateString()) .Set(PublishipAdvanceOrderTable.Columns.CancelRequestByID).EqualTo(_user) .Where(PublishipAdvanceOrderTable.Columns.OrderID).IsEqualTo(_id).Execute(); //confirm request received to client and publiship if (_updated > 0) { //string _test = return_html_content(_enum, _f); send_advance_email(_id.ToString(), "Cancellation request for order ID " + _id.ToString() + " from " + _uname, return_html_content(_enum, _f)); } } } }
protected void Submit_Click(object sender, EventArgs e) { bool cancel = false; ASPxGridView grid = POAddEditGrid as ASPxGridView; for (int i = 0; i < grid.VisibleRowCount; i++) { object taxgroup = grid.GetRowValues(i, "TaxGroup"); object taxitemgroup = grid.GetRowValues(i, "TaxItemGroup"); object identifier = grid.GetRowValues(i, "Identifier"); object cip = grid.GetRowValues(i, "CapexCIP"); object prodcat = grid.GetRowValues(i, "ProdCat"); if (string.IsNullOrEmpty(taxgroup.ToString()) || string.IsNullOrEmpty(taxitemgroup.ToString())) { cancel = true; break; } if (identifier.ToString() == "4") { MRPClass.PrintString(prodcat.ToString()); MRPClass.PrintString(string.IsNullOrEmpty(cip.ToString()).ToString()); if (prodcat.ToString() != "CIP") { if (string.IsNullOrEmpty(cip.ToString())) { cancel = true; break; } } } } if (cancel)//if empty taxgroup this is true { ModalPopupExtenderLoading.Hide(); PONotify.HeaderText = "Alert"; PONotifyLbl.Text = "Some selected items are empty."; PONotify.ShowOnPageLoad = true; } else { if (grid.VisibleRowCount > 0) { //Submit_Method(); //POClass.SubmitToAX(ponumber, PONotify, PONotifyLbl, ModalPopupExtenderLoading); POClass.SubmitToAXTable(ponumber, Session["UserCompleteName"].ToString(), PONotify, PONotifyLbl, ModalPopupExtenderLoading); } else { ModalPopupExtenderLoading.Hide(); Submit.ClientEnabled = false; PONotify.HeaderText = "Alert"; PONotifyLbl.Text = "No data to submit"; PONotify.ShowOnPageLoad = true; } } ScriptManager.RegisterStartupScript(this.Page, typeof(string), "Resize", "changeWidth.resizeWidth();", true); BindData(); }
public static void Save_HLSSOA(string sSOANum, DateTime dSOADate, int iYear, int iWeek, string sCustCode, string sRemarks, string sPreparedBy, string sPreparedByPost, string sCheckedBy, string sCheckedByPost, string sApprovedBy, string sApprovedByPost, ASPxGridView grdWaybills, string sAttention, string sAttentionNum) { SqlConnection cn = new SqlConnection(GlobalClass.SQLConnString()); SqlCommand cmdIns = null; DataTable dt = new DataTable(); SqlCommand cmd = null; SqlDataAdapter adp; int iMasterKey = 0; cn.Open(); string sInsert = "INSERT INTO tbl_HLS_StatementOfAccount (SOANum, SOADate, YearNo, WeekNo, CustomerCode, Remarks, PreparedBy, PreparedByPost, CheckedBy, CheckedByPost, ApprovedBy, ApprovedByPost) VALUES (@SOANum, @SOADate, @YearNo, @WeekNo, @CustomerCode, @Remarks, @PreparedBy, @PreparedByPost, @CheckedBy, @CheckedByPost, @ApprovedBy, @ApprovedByPost)"; cmdIns = new SqlCommand(sInsert, cn); cmdIns.Parameters.AddWithValue("@SOANum", sSOANum); cmdIns.Parameters.AddWithValue("@SOADate", dSOADate); cmdIns.Parameters.AddWithValue("@YearNo", iYear); cmdIns.Parameters.AddWithValue("@WeekNo", iWeek); cmdIns.Parameters.AddWithValue("@CustomerCode", sCustCode); cmdIns.Parameters.AddWithValue("@Remarks", sRemarks); cmdIns.Parameters.AddWithValue("@PreparedBy", sPreparedBy); cmdIns.Parameters.AddWithValue("@PreparedByPost", sPreparedByPost); cmdIns.Parameters.AddWithValue("@CheckedBy", sCheckedBy); cmdIns.Parameters.AddWithValue("@CheckedByPost", sCheckedByPost); cmdIns.Parameters.AddWithValue("@ApprovedBy", sApprovedBy); cmdIns.Parameters.AddWithValue("@ApprovedByPost", sApprovedByPost); cmdIns.ExecuteNonQuery(); string query = "SELECT PK FROM tbl_HLS_StatementOfAccount WHERE (SOANum = '" + sSOANum + "')"; cmd = new SqlCommand(query); cmd.Connection = cn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { iMasterKey = Convert.ToInt32(row["PK"]); } } dt.Clear(); if (iMasterKey > 0) { for (int i = 0; i <= (grdWaybills.VisibleRowCount - 1); i++) { object keyValue = grdWaybills.GetRowValues(i, "Waybill"); sInsert = "INSERT INTO tbl_HLS_StatementOfAccount_Details (MasterKey, Line, WaybillNum) VALUES (@MasterKey, @Line, @WaybillNum)"; cmdIns = new SqlCommand(sInsert, cn); cmdIns.Parameters.AddWithValue("@MasterKey", iMasterKey); cmdIns.Parameters.AddWithValue("@Line", i + 1); cmdIns.Parameters.AddWithValue("@WaybillNum", keyValue.ToString()); cmdIns.ExecuteNonQuery(); } } query = "SELECT tbl_HLS_CustomerAttention.* FROM tbl_HLS_CustomerAttention WHERE (CustCode = '" + sCustCode + "')"; cmd = new SqlCommand(query); cmd.Connection = cn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { sInsert = "UPDATE tbl_HLS_CustomerAttention SET AttentionName = @AttentionName, AttentionNumber = @AttentionNumber) WHERE (CustCode = @CustCode)"; cmdIns = new SqlCommand(sInsert, cn); cmdIns.Parameters.AddWithValue("@CustCode", sCustCode); cmdIns.Parameters.AddWithValue("@AttentionName", sAttention); cmdIns.Parameters.AddWithValue("@AttentionNumber", sAttentionNum); cmdIns.ExecuteNonQuery(); } else { sInsert = "INSERT INTO tbl_HLS_CustomerAttention (CustCode, AttentionName, AttentionNumber) VALUES (@CustCode, @AttentionName, @AttentionNumber)"; cmdIns = new SqlCommand(sInsert, cn); cmdIns.Parameters.AddWithValue("@CustCode", sCustCode); cmdIns.Parameters.AddWithValue("@AttentionName", sAttention); cmdIns.Parameters.AddWithValue("@AttentionNumber", sAttentionNum); cmdIns.ExecuteNonQuery(); } dt.Clear(); cn.Close(); }
object GetVersionField(ASPxGridView grid) { return(grid.GetRowValues(grid.EditingRowVisibleIndex, "Version")); }
private TaskStruct GetTSFromGV(ASPxGridView gridView) { TaskStruct res = new TaskStruct(); res.Description = (string)gridView.GetRowValues(gridView.FocusedRowIndex, "f1"); res.Value = (string)gridView.GetRowValues(gridView.FocusedRowIndex, "f2"); Page.DataBind(); return res; }
//Metodo que se ejecuta cuando se da clic en botón eliminar, descargar archivo o procesar archivo protected void ASPxGridView1_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridViewCustomButtonCallbackEventArgs e) { try { if (Session["Cadena"] == null) { Response.Redirect("Login.aspx"); return; } //ds_filesDS.ConnectionString = Session["Cadena"].ToString(); string cmdString = string.Empty; string connString = Session["Cadena"].ToString(); ASPxGridView grid = sender as ASPxGridView; var tmp = grid.GetRowValues(e.VisibleIndex, grid.KeyFieldName); DataTable dt = new DataTable(); if (e.ButtonID == "btnEliminar") { cmdString = "DELETE FROM [FILESPECA] WHERE [FPKEY] = @FPKEY"; using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandText = cmdString; comm.Parameters.Add("@FPKEY", SqlDbType.UniqueIdentifier).Value = tmp; using (SqlDataReader reader = comm.ExecuteReader()) { if (!reader.HasRows) { dt = null; } else { dt.Load(reader); } } } conn.Close(); } //Se actualiza grid UpdateGrid(); AlertSuccess("Archivo eliminado con éxito"); } else if (e.ButtonID == "ID_DOWNLOAD") { byte[] bytes = null; string nombreArchivo = ""; var parent = System.IO.Directory.GetParent(Environment.CurrentDirectory); string path = parent.Parent + "\\DS"; string target = path + ""; //Crea un directorio if (!Directory.Exists(target)) { Directory.CreateDirectory(target); } cmdString = "SELECT TOP 1 ARCHIVO, PECANAME FROM [FILESPECA] WHERE [FPKEY] = @val1 "; using (SqlConnection conn = new SqlConnection(connString)) { using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandText = cmdString; comm.Parameters.Add("@val1", SqlDbType.UniqueIdentifier).Value = tmp; conn.Open(); SqlDataReader reader = comm.ExecuteReader(); if (!reader.HasRows) { dt = null; } else { reader.Read(); bytes = (byte[])reader["ARCHIVO"]; nombreArchivo = (string)reader["PECANAME"]; File.WriteAllBytes(path + "\\" + nombreArchivo, bytes); AlertSuccess("Se descargo el archivo: " + nombreArchivo); } } //(sender as ASPxGridView).JSProperties["cpResult"] = "DS\\" + nombreArchivo; conn.Close(); } } if (e.ButtonID == "ID_PROCESAR") { // AQUI SE DEBE MANDAR A EJECUTAR EL SP QUE PROCESA LOS ARCHIVOS. try { string rfc = Session["RFC"].ToString().Trim(); if (rfc == null) { Response.Redirect("Login.aspx"); return; } TRespuesta res; IExpedienteComercioservice v1 = new IExpedienteComercioservice(); res = v1.Procesapeca(tmp.ToString(), rfc); string respuesta = res.ToString(); } catch (Exception exc) { int idusuario = 0; string mensaje = ""; if (Session["IdUsuario"] != null) { idusuario = int.Parse(Session["IdUsuario"].ToString()); } excepcion.RegistrarExcepcion(idusuario, "ASPxGridView1_CustomButtonCallback", exc, lblCadena.Text, ref mensaje); AlertError("Error al conectarse con el WebServices, intentelo más tarde"); } //Se actualiza grid UpdateGrid(); } } catch (Exception ex) { AlertError(ex.Message); int idusuario = 0; string mensaje = ""; if (Session["IdUsuario"] != null) { idusuario = int.Parse(Session["IdUsuario"].ToString()); } excepcion.RegistrarExcepcion(idusuario, "CargasPeca-ASPxGridView1_CustomButtonCallback", ex, lblCadena.Text, ref mensaje); } }
protected void Save_Click(object sender, EventArgs e) { CheckCreatorKey(); SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString()); conn.Open(); SqlDataReader reader = null; SqlCommand cmd = null; DataTable dt = new DataTable(); SqlDataAdapter adp; //Declare Variables string DocPref = "", strDocNum = "", PONumber = "", delete = "", update = "", query = "", insert = "", insert_po_details = ""; int POSeriesNum = 0; string mopnumber = MOPReference.Text; string entitycode = "", bucode = ""; query = "SELECT [PK],[EntityCode],[BUCode] FROM[dbo].[tbl_MRP_List] WHERE DocNumber = '" + mopnumber + "'"; cmd = new SqlCommand(query, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { entitycode = reader["EntityCode"].ToString(); bucode = reader["BUCode"].ToString(); } reader.Close(); string vendor = Vendor.Text.ToString(); string payment = Terms.Text.ToString(); string currency = Currency.Text.ToString(); string site = Site.Text.ToString(); string warehouse = Warehouse.Text.ToString(); string location = Location.Text.ToString(); string remarks = Remarks.Text.ToString(); query = "SELECT tbl_PONumber.* FROM tbl_PONumber WHERE (EntityCode = '" + entitycode + "')"; cmd = new SqlCommand(query); cmd.Connection = conn; adp = new SqlDataAdapter(cmd); adp.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { POSeriesNum = Convert.ToInt32(row["LastNumber"]) + 1; PONumber = row["Prefix"].ToString() + "-" + row["EntityCode"].ToString() + "-" + row["BeforeSeries"].ToString() + POSeriesNum.ToString("0000000#"); insert = "INSERT INTO [dbo].[tbl_POCreation] ([PONumber],[DateCreated],[CreatorKey],[MRPNumber], [ExpectedDate], [VendorCode], [PaymentTerms], [CurrencyCode], [InventSite], [InventSiteWarehouse], [InventSiteWarehouseLocation], [EntityCode], [BUSSUCode], [Remarks]) VALUES (@PONumber, @DateCreated, @CreatorKey, @MRPNumber, @ExpectedDate, @VendorCode, @PaymentTerms, @CurrencyCode, @InventSite, @InventSiteWarehouse, @InventSiteWarehouseLocation, @EntityCode, @BUSSUCode, @Remarks)"; cmd = new SqlCommand(insert, conn); cmd.Parameters.AddWithValue("@PONumber", PONumber); cmd.Parameters.AddWithValue("@CreatorKey", Session["CreatorKey"].ToString()); cmd.Parameters.AddWithValue("@MRPNumber", mopnumber); cmd.Parameters.AddWithValue("@EntityCode", entitycode); cmd.Parameters.AddWithValue("@BUSSUCode", bucode); cmd.Parameters.AddWithValue("@DateCreated", DateTime.Now); cmd.Parameters.AddWithValue("@ExpectedDate", ExpDel.Value.ToString()); cmd.Parameters.AddWithValue("@VendorCode", vendor); cmd.Parameters.AddWithValue("@PaymentTerms", payment); cmd.Parameters.AddWithValue("@CurrencyCode", currency); cmd.Parameters.AddWithValue("@InventSite", site); cmd.Parameters.AddWithValue("@InventSiteWarehouse", warehouse); cmd.Parameters.AddWithValue("@InventSiteWarehouseLocation", location); cmd.Parameters.AddWithValue("@Remarks", remarks); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); ASPxGridView grid = POCreateGrid as ASPxGridView; for (int i = 0; i < grid.VisibleRowCount; i++) { object PK = grid.GetRowValues(i, "PK"); object MOPNumber = grid.GetRowValues(i, "MOPNumber"); object ItemPK = grid.GetRowValues(i, "ItemPK"); object TableIdentifier = grid.GetRowValues(i, "TableIdentifier"); object ItemCode = grid.GetRowValues(i, "ItemCode"); object Description = grid.GetRowValues(i, "Description"); object RequestedQty = grid.GetRowValues(i, "RequestedQty"); object Cost = grid.GetRowValues(i, "Cost"); object TotalCost = grid.GetRowValues(i, "TotalCost"); object POUOM = grid.GetRowValues(i, "POUOM"); object POQty = grid.GetRowValues(i, "POQty"); object POCost = grid.GetRowValues(i, "POCost"); object TotalPOCost = grid.GetRowValues(i, "TotalPOCost"); object wVAT = grid.GetRowValues(i, "wVAT"); object POCostwVAT = grid.GetRowValues(i, "POCostwVAT"); object TotalPOCostwVAT = grid.GetRowValues(i, "TotalPOCostwVAT"); object TaxGroup = grid.GetRowValues(i, "TaxGroup"); object TaxItemGroup = grid.GetRowValues(i, "TaxItemGroup"); int iVat = 0; if (Convert.ToBoolean(wVAT)) { iVat = 1; } insert_po_details = "INSERT INTO [dbo].[tbl_POCreation_Details] ([PONumber],[MOPNumber], [ItemPK], [Identifier], [ItemCode], [TaxGroup], [TaxItemGroup], [Qty], [Cost], [POUOM], [wVAT], [CostwVAT]) VALUES (@PONumber,@MOPNumber, @ItemPK, @Identifier, @ItemCode, @TaxGroup, @TaxItemGroup, @Qty, @Cost, @POUOM, @wVAT, @CostwVAT)"; cmd = new SqlCommand(insert_po_details, conn); cmd.Parameters.AddWithValue("@PONumber", PONumber); cmd.Parameters.AddWithValue("@MOPNumber", MOPNumber); cmd.Parameters.AddWithValue("@ItemPK", ItemPK); cmd.Parameters.AddWithValue("@Identifier", TableIdentifier); cmd.Parameters.AddWithValue("@ItemCode", ItemCode); cmd.Parameters.AddWithValue("@TaxGroup", TaxGroup); cmd.Parameters.AddWithValue("@TaxItemGroup", TaxItemGroup); cmd.Parameters.AddWithValue("@POUOM", POUOM); cmd.Parameters.AddWithValue("@Qty", Convert.ToDouble(POQty)); cmd.Parameters.AddWithValue("@Cost", Convert.ToDouble(POCost)); //cmd.Parameters.AddWithValue("@TotalCost", Convert.ToDouble(TotalPOCost)); cmd.Parameters.AddWithValue("@CostwVAT", Convert.ToDouble(POCostwVAT)); //cmd.Parameters.AddWithValue("@TotalCostwVAT", Convert.ToDouble(TotalPOCostwVAT)); cmd.Parameters.AddWithValue("@wVAT", iVat); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); switch (TableIdentifier.ToString()) { case "1": //Direct Material update = "UPDATE " + MRP_Constants.DirectMaterials_TableName() + " SET [QtyPO] = '" + Convert.ToDouble(POQty) + "' WHERE [PK] = '" + ItemPK + "'"; cmd = new SqlCommand(update, conn); cmd.ExecuteNonQuery(); break; case "2": //Opex update = "UPDATE " + MRP_Constants.OperatingExpense_TableName() + " SET [QtyPO] = '" + Convert.ToDouble(POQty) + "' WHERE [PK] = '" + ItemPK + "'"; cmd = new SqlCommand(update, conn); cmd.ExecuteNonQuery(); break; case "4": //CAPEX update = "UPDATE [dbo].[tbl_MRP_List_CAPEX] SET [QtyPO] = '" + Convert.ToDouble(POQty) + "' WHERE [PK] = '" + ItemPK + "'"; cmd = new SqlCommand(update, conn); cmd.ExecuteNonQuery(); break; } } delete = "DELETE FROM [dbo].[tbl_POCreation_Tmp] WHERE [UserKey] = '" + Session["CreatorKey"].ToString() + "'"; cmd = new SqlCommand(delete, conn); cmd.ExecuteNonQuery(); update = "UPDATE [dbo].[tbl_PONumber] SET LastNumber = " + POSeriesNum + " WHERE ([EntityCode] = '" + entitycode + "')"; cmd = new SqlCommand(update, conn); cmd.ExecuteNonQuery(); ModalPopupExtenderLoading.Hide(); Response.Redirect("mrp_po_addedit.aspx?PONum=" + PONumber); } } else { ScriptManager.RegisterStartupScript(this.Page, typeof(string), "Resize", "changeWidth.resizeWidth();", true); POCreateNotify.HeaderText = "Alert!"; POCreateNotifyLbl.Text = "Please Call Administrator." + Environment.NewLine + Environment.NewLine + "No PO Number Setup."; POCreateNotifyLbl.ForeColor = System.Drawing.Color.Red; POCreateNotify.ShowOnPageLoad = true; } dt.Clear(); conn.Close(); }
public string ObtenerObjeto(sgwMulticapa.Objetos.Base.ObjetoBase AObjeto, ASPxGridView AGrilla) { return(ObtenerObjeto(AObjeto, int.Parse(AGrilla.GetRowValues(AGrilla.FocusedRowIndex, "ID_" + AObjeto.GetType().GetField("Entidad").GetValue(null).ToString()).ToString()))); }
public void ASPxGridView1_CustomButtonInitialize(object sender, ASPxGridViewCustomButtonEventArgs e) { ASPxGridView grid = (ASPxGridView)sender; string run_flag = grid.GetRowValues(e.VisibleIndex, "RUN_FLAG") as string; string item_flag = grid.GetRowValues(e.VisibleIndex, "ITEM_FLAG") as string; string third_flag = grid.GetRowValues(e.VisibleIndex, "THIRD_FLAG") as string; string confirm_flag = grid.GetRowValues(e.VisibleIndex, "CONFIRM_FLAG") as string; string bom_flag = grid.GetRowValues(e.VisibleIndex, "BOM_FLAG") as string; switch (e.ButtonID) { case "Cbt1": if (e.CellType == GridViewTableCommandCellType.Filter) { break; } if (item_flag != "N") { e.Visible = DefaultBoolean.False; } if (item_flag == "N") { e.Visible = DefaultBoolean.True; } if (confirm_flag == "N") { e.Visible = DefaultBoolean.False; } if (bom_flag == "N") { e.Visible = DefaultBoolean.False; } if (run_flag != "N") { e.Visible = DefaultBoolean.False; } break; case "Cbt2": if (e.CellType == GridViewTableCommandCellType.Filter) { break; } if (item_flag == "R") { e.Visible = DefaultBoolean.True; } if (item_flag != "R") { e.Visible = DefaultBoolean.False; } if (confirm_flag == "N") { e.Visible = DefaultBoolean.False; } if (bom_flag == "N") { e.Visible = DefaultBoolean.False; } if (run_flag != "N") { e.Visible = DefaultBoolean.False; } break; case "Confirm": if (e.CellType == GridViewTableCommandCellType.Filter) { break; } if (item_flag == "R") { e.Visible = DefaultBoolean.True; } if (item_flag != "R") { e.Visible = DefaultBoolean.False; } if (confirm_flag == "N") { e.Visible = DefaultBoolean.False; } if (bom_flag == "N") { e.Visible = DefaultBoolean.False; } if (run_flag != "N") { e.Visible = DefaultBoolean.False; } break; case "Cancel": //if (item_flag == "Y" && confirm_flag == "Y" && run_flag == "Y") if (e.CellType == GridViewTableCommandCellType.Filter) { break; } if (item_flag == "Y") { e.Visible = DefaultBoolean.True; } if (item_flag != "Y") { e.Visible = DefaultBoolean.False; } if (third_flag == "P") //正参与三方物料计算的不能取消确认 { e.Visible = DefaultBoolean.False; } if (confirm_flag == "N") { e.Visible = DefaultBoolean.False; } if (bom_flag == "N") { e.Visible = DefaultBoolean.False; } if (run_flag != "N") { e.Visible = DefaultBoolean.False; } break; } }
private List<object> GetSelectedRowValues(string aColumnName, string keyColumnName, string colunaAuxilizar, ASPxGridView Grid) { List<object> matrix = new List<object>(); // List<object> values = new List<object>(); string[] keyValueToGet = { keyColumnName }; string[] valueToGet = { aColumnName }; string[] colunaAUX = { colunaAuxilizar }; for (int i = 0; i < Grid.VisibleRowCount; i++) { if (Grid.Selection.IsRowSelected(i)) { List<object> values = new List<object>(); values.Add(Grid.GetRowValues(i, valueToGet)); values.Add(Grid.GetRowValues(i, keyValueToGet)); values.Add(Grid.GetRowValues(i, colunaAUX)); matrix.Add(values); } } return matrix; }
private DataTable GetDataView(ASPxGridView grid) { DataTable dt = new DataTable(); foreach (GridViewColumn col in grid.VisibleColumns) { GridViewDataColumn dataColumn = col as GridViewDataColumn; if (dataColumn == null) continue; dt.Columns.Add(dataColumn.FieldName); } for (int i = 0; i < grid.VisibleRowCount; i++) { DataRow row = dt.Rows.Add(); foreach (DataColumn col in dt.Columns) row[col.ColumnName] = grid.GetRowValues(i, col.ColumnName); } return dt; }
//Metodo que se ejecuta cuando se da clic en botón eliminar, descargar archivo o procesar archivo protected void ASPxGridView1_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridViewCustomButtonCallbackEventArgs e) { try { if (Session["Cadena"] == null) { Response.Redirect("Login.aspx"); return; } //ds_filesDS.ConnectionString = Session["Cadena"].ToString(); string cmdString = string.Empty; string connString = Session["Cadena"].ToString(); ASPxGridView grid = sender as ASPxGridView; var tmp = grid.GetRowValues(e.VisibleIndex, grid.KeyFieldName); DataTable dt = new DataTable(); if (e.ButtonID == "btnEliminar") { cmdString = "DELETE FROM [FILESDS] WHERE [FILESDSKEY] = @FILESDSKEY"; using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandText = cmdString; comm.Parameters.Add("@FILESDSKEY", SqlDbType.UniqueIdentifier).Value = tmp; using (SqlDataReader reader = comm.ExecuteReader()) { if (!reader.HasRows) { dt = null; } else { dt.Load(reader); } } } conn.Close(); } //Se actualiza grid UpdateGrid(); AlertSuccess("Archivo eliminado con éxito"); } else if (e.ButtonID == "ID_DOWNLOAD") { byte[] bytes = null; string nombreArchivo = ""; var parent = System.IO.Directory.GetParent(Environment.CurrentDirectory); string path = parent.Parent + "\\DS"; string target = path + ""; //Crea un directorio if (!Directory.Exists(target)) { Directory.CreateDirectory(target); } cmdString = "SELECT TOP 1 ARCHIVO, DSNAME FROM [FILESDS] WHERE [FILESDSKEY] = @val1 "; using (SqlConnection conn = new SqlConnection(connString)) { using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandText = cmdString; comm.Parameters.Add("@val1", SqlDbType.UniqueIdentifier).Value = tmp; conn.Open(); SqlDataReader reader = comm.ExecuteReader(); if (!reader.HasRows) { dt = null; } else { reader.Read(); bytes = (byte[])reader["ARCHIVO"]; nombreArchivo = (string)reader["DSNAME"]; File.WriteAllBytes(path + "\\" + nombreArchivo, bytes); AlertSuccess("Se descargo el archivo: " + nombreArchivo); } } //(sender as ASPxGridView).JSProperties["cpResult"] = "DS\\" + nombreArchivo; conn.Close(); } // Response.Clear(); // Response.ContentType = "application/winrar"; // Response.AddHeader("content-disposition", "attachment;filename=" + nombreArchivo); //// Response.TransmitFile(Server.MapPath(path + "\\" + nombreArchivo)); // Response.TransmitFile(path + "\\" + nombreArchivo); // HttpContext.Current.ApplicationInstance.CompleteRequest(); // Response.End(); } if (e.ButtonID == "ID_PROCESAR") { // AQUI SE DEBE MANDAR A EJECUTAR EL SP QUE PROCESA LOS ARCHIVOS. try { string rfc = Session["RFC"].ToString().Trim(); if (rfc == null) { Response.Redirect("Login.aspx"); return; } TRespuesta res; IExpedienteComercioservice v1 = new IExpedienteComercioservice(); res = v1.Procesads(tmp.ToString(), rfc); string respuesta = res.ToString(); } catch (Exception exc) { int idusuario = 0; string mensaje = ""; if (Session["IdUsuario"] != null) { idusuario = int.Parse(Session["IdUsuario"].ToString()); } excepcion.RegistrarExcepcion(idusuario, "CargasDataStage-ASPxGridView1_CustomButtonCallback", exc, lblCadena.Text, ref mensaje); AlertError("Error al conectarse con el WebServices, intentelo más tarde"); } #region codigo anterior ////Valida de cada fila del grid si el estatus esta Procesado entonces el botón Procesar Archivo queda inhabilitado //DataTable dtU = new DataTable(); //dtU = UpdateGrid(); //Session["Grid"] = dtU; //if (Session["Grid"] != null && ((DataTable)(Session["Grid"])).Rows.Count > 0) //{ // for (int i = 0; i < ((DataTable)(Session["Grid"])).Rows.Count; i++) // { // var status = grid.GetRowValues(i, "STATUSDS"); // if(status.ToString().ToUpper().Trim().Equals("PROCESADO")) // { // ASPxButton button = grid.FindRowCellTemplateControl(i, (GridViewDataColumn)grid.Columns["ACCION"], "ID_PROCESAR") as ASPxButton; // var col = ASPxGridView1. Columns[8] as GridViewCommandColumn; // col.CustomButtons["ID_PROCESAR"].Visibility = GridViewCustomButtonVisibility.Invisible; // } // //ASPxCheckBox chkConsultar = detailGridDocumentos.FindRowCellTemplateControl(i, (GridViewDataColumn)detailGridDocumentos.Columns["PDF"], "chkConsultar") as ASPxCheckBox; // //ASPxCheckBox chkConsultar = Grid2.FindRowCellTemplateControl(i, (GridViewDataColumn)Grid2.Columns["Consultar"], "chkConsultar") as ASPxCheckBox; // //ASPxButton btnProcesarFile = ASPxGridView1.FindRowCellTemplateControl(i, (GridViewDataColumn)ASPxGridView1.Columns["ACCIONES"], "btnProcesarFile") as ASPxButton; // //if (ASPxGridView1.GetRowValues(i, "STATUSDS").ToString().Equals("PROCESADO")) // // btnProcesarFile.Enabled = false; // //else // // btnProcesarFile.Enabled = true; // } // //foreach (DataRow fila in ((DataTable)(Session["Grid"])).Rows) // //{ // // if (fila["STATUSDS"].ToString().Trim().ToUpper().Equals("PROCESADO")) // // { // // } // //} //} #endregion //Se actualiza grid UpdateGrid(); } } catch (Exception ex) { AlertError(ex.Message); int idusuario = 0; string mensaje = ""; if (Session["IdUsuario"] != null) { idusuario = int.Parse(Session["IdUsuario"].ToString()); } excepcion.RegistrarExcepcion(idusuario, "CargasDataStage-ASPxGridView1_CustomButtonCallback", ex, lblCadena.Text, ref mensaje); } }
protected void gvAudit_ToolbarItemClick(object source, DevExpress.Web.Data.ASPxGridViewToolbarItemClickEventArgs e) { ASPxGridView gridview = source as ASPxGridView; string activeLang = (Session["lang"] == null) ? Languages.Default : Utils.ConvertToTrimmedString(Session["lang"]); var auditId = Utils.ConvertToNullableInt(gridview.GetRowValues(gridview.FocusedRowIndex, "audit_id")); var auditDetailsId = Utils.ConvertToNullableInt(gridview.GetRowValues(gridview.FocusedRowIndex, "id")); var allowedOK = Utils.ConvertToNullableBool(gridview.GetRowValues(gridview.FocusedRowIndex, "answer_OK")); var allowedNOK = Utils.ConvertToNullableBool(gridview.GetRowValues(gridview.FocusedRowIndex, "answer_NOK")); var allowedNC = Utils.ConvertToNullableBool(gridview.GetRowValues(gridview.FocusedRowIndex, "answer_NC")); var allowedNA = Utils.ConvertToNullableBool(gridview.GetRowValues(gridview.FocusedRowIndex, "answer_NA")); if (allowedNA == null || allowedNC == null || allowedNOK == null || allowedOK == null || auditId == null || auditDetailsId == null) { throw new Exception("System error!"); } var audit = new Audit((int)auditId); if (!audit.AuditExist() || audit.EndDate != null) { throw new Exception("Audit does not exist / has already been completed!"); } bool refresh = false; bool move = false; switch (e.Item.Name) { case ToolbarButtons.NextPage: ChangePage(ToolbarButtons.NextPage); gridview.FocusedRowIndex = 0; refresh = true; break; case ToolbarButtons.PrevPage: ChangePage(ToolbarButtons.PrevPage); gridview.FocusedRowIndex = 0; refresh = true; break; case ToolbarButtons.LangPol: Session["lang"] = Languages.Polish; refresh = true; break; case ToolbarButtons.LangEng: Session["lang"] = Languages.English; refresh = true; break; case ToolbarButtons.AnswerOK: ProcessAnswer(auditDetailsId, Answers.OK, allowedOK, allowedNOK, allowedNC, allowedNA); refresh = true; move = true; break; case ToolbarButtons.AnswerNOK: ProcessAnswer(auditDetailsId, Answers.NOK, allowedOK, allowedNOK, allowedNC, allowedNA); refresh = true; break; case ToolbarButtons.AnswerNC: ProcessAnswer(auditDetailsId, Answers.NC, allowedOK, allowedNOK, allowedNC, allowedNA); refresh = true; break; case ToolbarButtons.AnswerNA: ProcessAnswer(auditDetailsId, Answers.NA, allowedOK, allowedNOK, allowedNC, allowedNA); refresh = true; move = true; break; case ToolbarButtons.Camera: Session["audit_id"] = auditId; Session["audit_detail_id"] = auditDetailsId; gridview.JSProperties["cp_launch_camera"] = true; break; case ToolbarButtons.DeleteAudit: audit.Delete(); gridview.JSProperties["cp_escape_page"] = true; Session["lang"] = null; Session["page"] = null; Session["audit_id"] = null; Session["audit_detail_id"] = null; Session["message"] = "Audit removed!"; break; case ToolbarButtons.PrintAudit: audit.SendEmailWithPdf(activeLang); break; case ToolbarButtons.EndAudit: if (audit.AuditQuestionAnsweredCount != audit.AuditQuestionCount) { throw new Exception("Answer all questions!"); } audit.End(); Session["lang"] = null; Session["page"] = null; Session["audit_id"] = null; Session["audit_detail_id"] = null; Session["message"] = $"Audit completed with score {audit.AuditScoreCalculated.ToString("#.##")}%!"; gridview.JSProperties["cp_escape_page"] = true; break; } if (refresh) { gridview.JSProperties["cp_refresh"] = true; } if (move) { gridview.JSProperties["cp_move"] = true; } }