protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Save" || e.CommandName == "Charge") { ValidateEditViewFields(m_sMODULE + ".EditView"); bool bIsValid = Page.IsValid; Decimal dAMOUNT = new DynamicControl(this, "AMOUNT").DecimalValue; if (dAMOUNT != ctlAllocationsView.ALLOCATED_TOTAL) { ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("Payments.ERR_AMOUNT_MUST_MATCH_ALLOCATION"); bIsValid = false; } if (bIsValid) { string sCUSTOM_MODULE = "PAYMENTS"; DataTable dtCustomFields = CRMCache.FieldsMetaData_Validated(sCUSTOM_MODULE); var oQuery = new InlineQueryDBManager(); DataRow rowCurrent = null; if (!CommonTypeConvert.IsEmptyGuid(gID)) { string innerSql = ApplicationSQL.SQL["Payments_EditView_259"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, m_sMODULE, "edit"); TypeConvert.AppendParameter(oQuery, gID, "ID", false); DataTable dtCurrent = oQuery.GetTable(); if (dtCurrent.Rows.Count > 0) { rowCurrent = dtCurrent.Rows[0]; } else { gID = Guid.Empty; } } Guid gASSIGNED_USER_ID = new DynamicControl(this, rowCurrent, "ASSIGNED_USER_ID").ID; Guid gACCOUNT_ID = new DynamicControl(this, rowCurrent, "ACCOUNT_ID").ID; DateTime dtPAYMENT_DATE = new DynamicControl(this, rowCurrent, "PAYMENT_DATE").DateValue; string sPAYMENT_TYPE = new DynamicControl(this, rowCurrent, "PAYMENT_TYPE").SelectedValue; string sCUSTOMER_REFERENCE = new DynamicControl(this, rowCurrent, "CUSTOMER_REFERENCE").Text; Guid gCURRENCY_ID = new DynamicControl(this, rowCurrent, "CURRENCY_ID").ID; string sDESCRIPTION = new DynamicControl(this, rowCurrent, "DESCRIPTION").Text; Guid gTEAM_ID = new DynamicControl(this, rowCurrent, "TEAM_ID").ID; Guid gCREDIT_CARD_ID = new DynamicControl(this, rowCurrent, "CREDIT_CARD_ID").ID; if (sPAYMENT_TYPE != "Credit Card") { gCREDIT_CARD_ID = Guid.Empty; } float fEXCHANGE_RATE = new DynamicControl(ctlAllocationsView, rowCurrent, "EXCHANGE_RATE").FloatValue; var sbINVOICE_NUMBER = new StringBuilder(); if (dtPAYMENT_DATE == ((DateTime)SqlDateTime.MinValue) || e.CommandName == "Charge") { dtPAYMENT_DATE = DateTime.Now; } CommonProcedure.PatmentsUpdate (ref gID , gASSIGNED_USER_ID , gACCOUNT_ID , dtPAYMENT_DATE , sPAYMENT_TYPE , sCUSTOMER_REFERENCE , fEXCHANGE_RATE , gCURRENCY_ID , dAMOUNT , sDESCRIPTION , gTEAM_ID , gCREDIT_CARD_ID ); CRMDynamic.UpdateCustomFields(this, gID, sCUSTOM_MODULE, dtCustomFields); DataTable dtLineItems = ctlAllocationsView.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.InvoicesPAYMENTS_Delete(gITEM_ID); } } } foreach (DataRow row in dtLineItems.Rows) { if (row.RowState != DataRowState.Deleted) { Guid gITEM_ID = CommonTypeConvert.ToGuid(row["ID"]); Guid gINVOICE_ID = CommonTypeConvert.ToGuid(row["INVOICE_ID"]); Decimal dINVOICE_AMOUNT = CommonTypeConvert.ToDecimal(row["AMOUNT"]); if (!CommonTypeConvert.IsEmptyGuid(gINVOICE_ID)) { CommonProcedure.InvoicesPAYMENTS_Update (ref gITEM_ID , gINVOICE_ID , gID , dINVOICE_AMOUNT ); if (sbINVOICE_NUMBER.Length > 0) { sbINVOICE_NUMBER.Append(","); } sbINVOICE_NUMBER.Append(gINVOICE_ID.ToString()); } } } ViewState["ID"] = gID; if (e.CommandName == "Charge") { sbINVOICE_NUMBER.Append(" " + DateTime.UtcNow); //CRM.Common.Charge.CC.Charge(Application, gID, gCURRENCY_ID, gACCOUNT_ID, gCREDIT_CARD_ID, Request.UserHostAddress, sbINVOICE_NUMBER.ToString(), sDESCRIPTION, dAMOUNT); } Response.Redirect("view.aspx?ID=" + gID); } } else if (e.CommandName == "Cancel") { if (CommonTypeConvert.IsEmptyGuid(gID)) { Response.Redirect("Index.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID); } } }
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); } } }
protected void Page_Command(Object sender, CommandEventArgs e) { 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") { var txtNAME = FindControl("NAME") as TextBox; var txtPRODUCT_TEMPLATE_ID = FindControl("PRODUCT_TEMPLATE_ID") as HtmlInputHidden; if (CommonTypeConvert.IsEmptyString(txtNAME.Text.Trim())) { txtPRODUCT_TEMPLATE_ID.Value = String.Empty; } else if (CommonTypeConvert.IsEmptyString(txtPRODUCT_TEMPLATE_ID.Value)) { txtPRODUCT_TEMPLATE_ID.Value = Guid.Empty.ToString(); } ValidateEditViewFields(m_sMODULE + ".EditView"); ValidateEditViewFields(m_sMODULE + ".CostView"); ValidateEditViewFields(m_sMODULE + ".MftView"); if (Page.IsValid) { string sCUSTOM_MODULE = "PRODUCTS"; DataTable dtCustomFields = CRMCache.FieldsMetaData_Validated(sCUSTOM_MODULE); var oQuery = new InlineQueryDBManager(); DataRow rowCurrent = null; if (!CommonTypeConvert.IsEmptyGuid(gID)) { string innerSql = ApplicationSQL.SQL["Products_EditView"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, m_sMODULE, "edit"); TypeConvert.AppendParameter(oQuery, gID, "ID", false); DataTable dtCurrent = oQuery.GetTable(); if (dtCurrent.Rows.Count > 0) { rowCurrent = dtCurrent.Rows[0]; } else { gID = Guid.Empty; } } CommonProcedure.ProductUpdate (ref gID , new DynamicControl(this, rowCurrent, "PRODUCT_TEMPLATE_ID").ID , new DynamicControl(this, rowCurrent, "NAME").Text , new DynamicControl(this, rowCurrent, "STATUS").SelectedValue , new DynamicControl(this, rowCurrent, "ACCOUNT_ID").ID , new DynamicControl(this, rowCurrent, "CONTACT_ID").ID , new DynamicControl(this, rowCurrent, "QUANTITY").IntegerValue , new DynamicControl(this, rowCurrent, "DATE_PURCHASED").DateValue , new DynamicControl(this, rowCurrent, "DATE_SUPPORT_EXPIRES").DateValue , new DynamicControl(this, rowCurrent, "DATE_SUPPORT_STARTS").DateValue , new DynamicControl(this, rowCurrent, "MANUFACTURER_ID").ID , new DynamicControl(this, rowCurrent, "CATEGORY_ID").ID , new DynamicControl(this, rowCurrent, "TYPE_ID").ID , new DynamicControl(this, rowCurrent, "WEBSITE").Text , new DynamicControl(this, rowCurrent, "MFT_PART_NUM").Text , new DynamicControl(this, rowCurrent, "VENDOR_PART_NUM").Text , new DynamicControl(this, rowCurrent, "SERIAL_NUMBER").Text , new DynamicControl(this, rowCurrent, "ASSET_NUMBER").Text , new DynamicControl(this, rowCurrent, "TAX_CLASS").SelectedValue , new DynamicControl(this, rowCurrent, "WEIGHT").FloatValue , new DynamicControl(this, rowCurrent, "CURRENCY_ID").ID , new DynamicControl(this, rowCurrent, "COST_PRICE").DecimalValue , new DynamicControl(this, rowCurrent, "LIST_PRICE").DecimalValue , new DynamicControl(this, rowCurrent, "BOOK_VALUE").DecimalValue , new DynamicControl(this, rowCurrent, "BOOK_VALUE_DATE").DateValue , new DynamicControl(this, rowCurrent, "DISCOUNT_PRICE").DecimalValue , new DynamicControl(this, rowCurrent, "PRICING_FACTOR").IntegerValue , new DynamicControl(this, rowCurrent, "PRICING_FORMULA").SelectedValue , new DynamicControl(this, rowCurrent, "SUPPORT_NAME").Text , new DynamicControl(this, rowCurrent, "SUPPORT_CONTACT").Text , new DynamicControl(this, rowCurrent, "SUPPORT_DESCRIPTION").Text , new DynamicControl(this, rowCurrent, "SUPPORT_TERM").SelectedValue , new DynamicControl(this, rowCurrent, "DESCRIPTION").Text , new DynamicControl(this, rowCurrent, "TEAM_ID").ID ); CRMDynamic.UpdateCustomFields(this, gID, sCUSTOM_MODULE, dtCustomFields); 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(gID)) { Response.Redirect("Index.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID); } } }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Save") { ValidateEditViewFields(m_sMODULE + ".EditView"); if (Page.IsValid) { string sCUSTOM_MODULE = "PRODUCT_TEMPLATES"; DataTable dtCustomFields = CRMCache.FieldsMetaData_Validated(sCUSTOM_MODULE); var oQuery = new InlineQueryDBManager(); DataRow rowCurrent = null; var dtCurrent = new DataTable(); if (!CommonTypeConvert.IsEmptyGuid(gID)) { string innerSql = ApplicationSQL.SQL["Administration_ProductTemplates_EditView_39"].ToString(); 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; } } CommonProcedure.ProductTemplatesUpdate (ref gID , new DynamicControl(this, rowCurrent, "NAME").Text , new DynamicControl(this, rowCurrent, "STATUS").SelectedValue , new DynamicControl(this, rowCurrent, "QUANTITY").IntegerValue , new DynamicControl(this, rowCurrent, "DATE_AVAILABLE").DateValue , new DynamicControl(this, rowCurrent, "DATE_COST_PRICE").DateValue , new DynamicControl(this, rowCurrent, "ACCOUNT_ID").ID , new DynamicControl(this, rowCurrent, "MANUFACTURER_ID").ID , new DynamicControl(this, rowCurrent, "CATEGORY_ID").ID , new DynamicControl(this, rowCurrent, "TYPE_ID").ID , new DynamicControl(this, rowCurrent, "WEBSITE").Text , new DynamicControl(this, rowCurrent, "MFT_PART_NUM").Text , new DynamicControl(this, rowCurrent, "VENDOR_PART_NUM").Text , new DynamicControl(this, rowCurrent, "TAX_CLASS").SelectedValue , new DynamicControl(this, rowCurrent, "WEIGHT").FloatValue , new DynamicControl(this, rowCurrent, "CURRENCY_ID").ID , new DynamicControl(this, rowCurrent, "COST_PRICE").DecimalValue , new DynamicControl(this, rowCurrent, "LIST_PRICE").DecimalValue , new DynamicControl(this, rowCurrent, "DISCOUNT_PRICE").DecimalValue , new DynamicControl(this, rowCurrent, "PRICING_FACTOR").IntegerValue , new DynamicControl(this, rowCurrent, "PRICING_FORMULA").SelectedValue , new DynamicControl(this, rowCurrent, "SUPPORT_NAME").Text , new DynamicControl(this, rowCurrent, "SUPPORT_CONTACT").Text , new DynamicControl(this, rowCurrent, "SUPPORT_DESCRIPTION").Text , new DynamicControl(this, rowCurrent, "SUPPORT_TERM").SelectedValue , new DynamicControl(this, rowCurrent, "DESCRIPTION").Text ); CRMDynamic.UpdateCustomFields(this, gID, sCUSTOM_MODULE, dtCustomFields); Response.Redirect("view.aspx?ID=" + gID); } } else if (e.CommandName == "Cancel") { if (CommonTypeConvert.IsEmptyGuid(gID)) { Response.Redirect("Index.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID); } } }