protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Save" || e.CommandName == "SaveNew") { if (Page.IsValid) { Guid gPARENT_ID = CommonTypeConvert.ToGuid(txtPARENT_ID.Value); if (gPARENT_ID == gID) { gPARENT_ID = Guid.Empty; } CommonProcedure.spPRODUCT_CATEGORIES_Update( ref gID , gPARENT_ID , txtNAME.Text , txtDESCRIPTION.Text , CommonTypeConvert.ToInteger(txtLIST_ORDER.Text) ); Cache.Remove("vwPRODUCT_CATEGORIES_LISTBOX"); if (e.CommandName == "SaveNew") { Response.Redirect("edit.aspx"); } else { Response.Redirect("Index.aspx"); } } } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term("Manufacturers.LBL_NAME")); Visible = Security.IS_ADMIN; Visible = Security.ADMIN_TYPE == 0 ? true : false; if (!Visible) { return; } reqNAME.DataBind(); reqLIST_ORDER.DataBind(); gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); lstSTATUS.DataSource = CRMCache.List("manufacturer_status_dom"); lstSTATUS.DataBind(); if (!CommonTypeConvert.IsEmptyGuid(gID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Administration_Manufacturers_EditView"].ToString(); oQuery.CommandText = innerSql; oQuery.Add("@ID", SqlDbType.UniqueIdentifier, gID); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { txtNAME.Text = CommonTypeConvert.ToString(rdr["NAME"]); ctlListHeader.Title = Translation.GetTranslation.Term("Manufacturers.LBL_NAME") + " " + txtNAME.Text; txtLIST_ORDER.Text = CommonTypeConvert.ToString(rdr["LIST_ORDER"]); lstSTATUS.SelectedValue = CommonTypeConvert.ToString(rdr["STATUS"]); } } } else { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Manufacturers_EditView_113"].ToString(); oQuery.CommandText = innerSql; txtLIST_ORDER.Text = (CommonTypeConvert.ToInteger(oQuery.ExecuteScalar()) + 1).ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term("ProductTypes.LBL_NAME")); if (!Visible) { return; } reqNAME.DataBind(); reqLIST_ORDER.DataBind(); gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); if (!CommonTypeConvert.IsEmptyGuid(gID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Administration_ProductTypes_EditView"].ToString(); oQuery.CommandText = innerSql; oQuery.Add("@ID", SqlDbType.UniqueIdentifier, gID); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { txtNAME.Text = CommonTypeConvert.ToString(rdr["NAME"]); ctlListHeader.Title = Translation.GetTranslation.Term("ProductTypes.LBL_NAME") + " " + txtNAME.Text; txtDESCRIPTION.Text = CommonTypeConvert.ToString(rdr["DESCRIPTION"]); txtLIST_ORDER.Text = CommonTypeConvert.ToString(rdr["LIST_ORDER"]); } } } else { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["ProductTypes_EditView_104"].ToString(); oQuery.CommandText = innerSql; txtLIST_ORDER.Text = (CommonTypeConvert.ToInteger(oQuery.ExecuteScalar()) + 1).ToString(); } } }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Save" || e.CommandName == "SaveNew") { if (Page.IsValid) { CommonProcedure.ManufacturersUpdate( ref gID , txtNAME.Text , lstSTATUS.SelectedValue , CommonTypeConvert.ToInteger(txtLIST_ORDER.Text) ); Cache.Remove("vwMANUFACTURERS_LISTBOX"); if (e.CommandName == "SaveNew") { Response.Redirect("edit.aspx"); } else { Response.Redirect("Index.aspx"); } } } }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Save" || e.CommandName == "SaveNew") { if (Page.IsValid) { CommonProcedure.ProductTypesUpdate( ref gID , txtNAME.Text , txtDESCRIPTION.Text , CommonTypeConvert.ToInteger(txtLIST_ORDER.Text) ); Cache.Remove("vwPRODUCT_TYPES_LISTBOX"); if (e.CommandName == "SaveNew") { Response.Redirect("edit.aspx"); } else { Response.Redirect("Index.aspx"); } } } }
public static DataTable ImportColumns(string sMODULE_NAME) { Cache Cache = HttpRuntime.Cache; var dt = Cache.Get("vwSqlColumns_Import." + sMODULE_NAME) as DataTable; if (dt == null) { string sTABLE_NAME = CommonTypeConvert.ToString(HttpContext.Current.Application["Modules." + sMODULE_NAME + ".TableName"]); if (CommonTypeConvert.IsEmptyString(sTABLE_NAME)) { sTABLE_NAME = sMODULE_NAME.ToUpper(); } var oQuery = new InlineQueryDBManager(); dt = new DataTable(); dt.Columns.Add("ColumnName", Type.GetType("System.String")); dt.Columns.Add("NAME", Type.GetType("System.String")); dt.Columns.Add("DISPLAY_NAME", Type.GetType("System.String")); dt.Columns.Add("ColumnType", Type.GetType("System.String")); dt.Columns.Add("Size", Type.GetType("System.Int32")); dt.Columns.Add("Scale", Type.GetType("System.Int32")); dt.Columns.Add("Precision", Type.GetType("System.Int32")); dt.Columns.Add("colid", Type.GetType("System.Int32")); dt.Columns.Add("CustomField", Type.GetType("System.Boolean")); { oQuery = null; try { oQuery = InlineQueryDBManager.Factory("stp_Zpro_" + sTABLE_NAME + "_Import"); if (oQuery == null) { throw new Exception(); } } catch { oQuery = InlineQueryDBManager.Factory("stp_Zpro_" + sTABLE_NAME + "_Update"); } for (int i = 0; i < oQuery.Count; i++) { SqlParameter par = oQuery[i]; DataRow row = dt.NewRow(); dt.Rows.Add(row); row["ColumnName"] = par.ParameterName; row["NAME"] = CommonTypeConvert.ExtractDbName(par.ParameterName); row["DISPLAY_NAME"] = row["NAME"]; row["ColumnType"] = par.DbType.ToString(); row["Size"] = par.Size; row["Scale"] = par.Scale; row["Precision"] = par.Precision; row["colid"] = i; row["CustomField"] = false; } string sSQL; if (Config.enable_team_management()) { bool bModuleIsTeamed = CommonTypeConvert.ToBoolean( HttpContext.Current.Application["Modules." + sMODULE_NAME + ".Teamed"]); DataRow row = dt.NewRow(); row = dt.NewRow(); row["ColumnName"] = "@TEAM_NAME"; row["NAME"] = "TEAM_NAME"; row["DISPLAY_NAME"] = "TEAM_NAME"; row["ColumnType"] = "string"; row["Size"] = 128; row["colid"] = dt.Rows.Count; row["CustomField"] = false; dt.Rows.Add(row); } sSQL = ApplicationSQL.SQL["_code_CRMCache_629"]; oQuery = new InlineQueryDBManager(); oQuery.CommandText = sSQL; oQuery.Add("@OBJECTNAME", SqlDbType.NVarChar, sTABLE_NAME + "_CSTM"); DataTable dtCSTM = oQuery.GetTable(); foreach (DataRow rowCSTM in dtCSTM.Rows) { DataRow row = dt.NewRow(); row["ColumnName"] = CommonTypeConvert.ToString(rowCSTM["ColumnName"]); row["NAME"] = CommonTypeConvert.ToString(rowCSTM["ColumnName"]); row["DISPLAY_NAME"] = CommonTypeConvert.ToString(rowCSTM["ColumnName"]); row["ColumnType"] = CommonTypeConvert.ToString(rowCSTM["CsType"]); row["Size"] = CommonTypeConvert.ToInteger(rowCSTM["length"]); row["colid"] = dt.Rows.Count; row["CustomField"] = true; dt.Rows.Add(row); } Cache.Insert("vwSqlColumns_Import." + sMODULE_NAME, dt, null, DefaultCacheExpiration(), Cache.NoSlidingExpiration); } } return(dt); //return new DataTable(); }
protected void Page_Command(Object sender, CommandEventArgs e) { Guid gORDER_ID = CommonTypeConvert.ToGuid(Request["ORDER_ID"]); Guid gQUOTE_ID = CommonTypeConvert.ToGuid(Request["QUOTE_ID"]); Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); string sMODULE = String.Empty; string sPARENT_TYPE = String.Empty; string sPARENT_NAME = String.Empty; CommonProcedure.ParentGet(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME); if (e.CommandName == "Save") { ValidateEditViewFields(m_sMODULE + ".EditView"); ValidateEditViewFields(m_sMODULE + ".EditAddress"); ValidateEditViewFields(m_sMODULE + ".EditDescription"); if (Page.IsValid) { string sCUSTOM_MODULE = "INVOICES"; DataTable dtCustomFields = CRMCache.FieldsMetaData_Validated(sCUSTOM_MODULE); DataTable dtCustomLineItems = CRMCache.FieldsMetaData_UnvalidatedCustomFields(sCUSTOM_MODULE + "_LINE_ITEMS"); DataRow rowCurrent = null; var dtCurrent = new DataTable(); if (!CommonTypeConvert.IsEmptyGuid(gID)) { string innerSql = ApplicationSQL.SQL["Invoices_EditView_323"].ToString(); var oQuery = new InlineQueryDBManager(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, m_sMODULE, "edit"); TypeConvert.AppendParameter(oQuery, gID, "ID", false); dtCurrent = oQuery.GetTable(); if (dtCurrent.Rows.Count > 0) { rowCurrent = dtCurrent.Rows[0]; } else { gID = Guid.Empty; } } ctlEditLineItemsView.UpdateTotals(); CommonProcedure.InvoicesUpdate (ref gID , new DynamicControl(this, rowCurrent, "ASSIGNED_USER_ID").ID , new DynamicControl(this, rowCurrent, "NAME").Text , new DynamicControl(this, rowCurrent, "QUOTE_ID").ID , new DynamicControl(this, rowCurrent, "ORDER_ID").ID , new DynamicControl(this, rowCurrent, "OPPORTUNITY_ID").ID , new DynamicControl(this, rowCurrent, "PAYMENT_TERMS").SelectedValue , new DynamicControl(this, rowCurrent, "INVOICE_STAGE").SelectedValue , new DynamicControl(this, rowCurrent, "PURCHASE_ORDER_NUM").Text , new DynamicControl(this, rowCurrent, "DUE_DATE").DateValue , new DynamicControl(ctlEditLineItemsView, rowCurrent, "EXCHANGE_RATE").FloatValue , new DynamicControl(ctlEditLineItemsView, rowCurrent, "CURRENCY_ID").ID , new DynamicControl(ctlEditLineItemsView, rowCurrent, "TAXRATE_ID").ID , new DynamicControl(ctlEditLineItemsView, rowCurrent, "SHIPPER_ID").ID , new DynamicControl(ctlEditLineItemsView, rowCurrent, "SUBTOTAL").DecimalValue , new DynamicControl(ctlEditLineItemsView, rowCurrent, "DISCOUNT").DecimalValue , new DynamicControl(ctlEditLineItemsView, rowCurrent, "SHIPPING").DecimalValue , new DynamicControl(ctlEditLineItemsView, rowCurrent, "TAX").DecimalValue , new DynamicControl(ctlEditLineItemsView, rowCurrent, "TOTAL").DecimalValue , new DynamicControl(ctlEditLineItemsView, rowCurrent, "AMOUNT_DUE").DecimalValue , new DynamicControl(this, rowCurrent, "BILLING_ACCOUNT_ID").ID , new DynamicControl(this, rowCurrent, "BILLING_CONTACT_ID").ID , new DynamicControl(this, rowCurrent, "BILLING_ADDRESS_STREET").Text , new DynamicControl(this, rowCurrent, "BILLING_ADDRESS_CITY").Text , new DynamicControl(this, rowCurrent, "BILLING_ADDRESS_STATE").Text , new DynamicControl(this, rowCurrent, "BILLING_ADDRESS_POSTALCODE").Text , new DynamicControl(this, rowCurrent, "BILLING_ADDRESS_COUNTRY").Text , new DynamicControl(this, rowCurrent, "SHIPPING_ACCOUNT_ID").ID , new DynamicControl(this, rowCurrent, "SHIPPING_CONTACT_ID").ID , new DynamicControl(this, rowCurrent, "SHIPPING_ADDRESS_STREET").Text , new DynamicControl(this, rowCurrent, "SHIPPING_ADDRESS_CITY").Text , new DynamicControl(this, rowCurrent, "SHIPPING_ADDRESS_STATE").Text , new DynamicControl(this, rowCurrent, "SHIPPING_ADDRESS_POSTALCODE").Text , new DynamicControl(this, rowCurrent, "SHIPPING_ADDRESS_COUNTRY").Text , new DynamicControl(this, rowCurrent, "DESCRIPTION").Text , new DynamicControl(this, rowCurrent, "TEAM_ID").ID ); CRMDynamic.UpdateCustomFields(this, gID, sCUSTOM_MODULE, dtCustomFields); DataTable dtLineItems = ctlEditLineItemsView.LineItems; foreach (DataRow row in dtLineItems.Rows) { if (row.RowState == DataRowState.Deleted) { Guid gITEM_ID = CommonTypeConvert.ToGuid(row["ID", DataRowVersion.Original]); if (!CommonTypeConvert.IsEmptyGuid(gITEM_ID)) { CommonProcedure.InvoicesLINE_ITEMS_Delete(gITEM_ID); } } } int nPOSITION = 1; foreach (DataRow row in dtLineItems.Rows) { if (row.RowState != DataRowState.Deleted) { Guid gITEM_ID = CommonTypeConvert.ToGuid(row["ID"]); Guid gLINE_GROUP_ID = CommonTypeConvert.ToGuid(row["LINE_GROUP_ID"]); string sLINE_ITEM_TYPE = CommonTypeConvert.ToString(row["LINE_ITEM_TYPE"]); string sNAME = CommonTypeConvert.ToString(row["NAME"]); string sMFT_PART_NUM = CommonTypeConvert.ToString(row["MFT_PART_NUM"]); string sVENDOR_PART_NUM = CommonTypeConvert.ToString(row["VENDOR_PART_NUM"]); Guid gPRODUCT_TEMPLATE_ID = CommonTypeConvert.ToGuid(row["PRODUCT_TEMPLATE_ID"]); string sTAX_CLASS = CommonTypeConvert.ToString(row["TAX_CLASS"]); int nQUANTITY = CommonTypeConvert.ToInteger(row["QUANTITY"]); Decimal dCOST_PRICE = CommonTypeConvert.ToDecimal(row["COST_PRICE"]); Decimal dLIST_PRICE = CommonTypeConvert.ToDecimal(row["LIST_PRICE"]); Decimal dUNIT_PRICE = CommonTypeConvert.ToDecimal(row["UNIT_PRICE"]); string sDESCRIPTION = CommonTypeConvert.ToString(row["DESCRIPTION"]); if (!CommonTypeConvert.IsEmptyGuid(gPRODUCT_TEMPLATE_ID) || !CommonTypeConvert.IsEmptyString(sNAME)) { CommonProcedure.InvoicesLINE_ITEMS_Update (ref gITEM_ID , gID , gLINE_GROUP_ID , sLINE_ITEM_TYPE , nPOSITION , sNAME , sMFT_PART_NUM , sVENDOR_PART_NUM , gPRODUCT_TEMPLATE_ID , sTAX_CLASS , nQUANTITY , dCOST_PRICE , dLIST_PRICE , dUNIT_PRICE , sDESCRIPTION ); CRMDynamic.UpdateCustomFields(row, gITEM_ID, sCUSTOM_MODULE + "_LINE_ITEMS", dtCustomLineItems); nPOSITION++; } } } CommonProcedure.InvoicesUpdateAmountDue(gID); if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID)) { Response.Redirect("~/CRM/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID); } else { Response.Redirect("view.aspx?ID=" + gID); } } } else if (e.CommandName == "Cancel") { if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID)) { Response.Redirect("~/CRM/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID); } else if (!CommonTypeConvert.IsEmptyGuid(gORDER_ID)) { Response.Redirect("~/CRM/Orders/view.aspx?ID=" + gORDER_ID); } else if (!CommonTypeConvert.IsEmptyGuid(gQUOTE_ID)) { Response.Redirect("~/CRM/Quotes/view.aspx?ID=" + gQUOTE_ID); } else if (CommonTypeConvert.IsEmptyGuid(gID)) { Response.Redirect("Index.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID); } } }