public Invoice GetInvoiceByName(Guid gCURRENCY_ID, string sNAME) { var item = new Invoice(); { if (Security.USER_ID == Guid.Empty) throw (new Exception("Authentication required")); var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Invoices_AutoComplete_50"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, "Invoices", "list"); TypeConvert.AppendParameter(oQuery, sNAME, CommonTypeConvert.SqlFilterMode.StartsWith, "NAME"); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { item.ID = CommonTypeConvert.ToGuid(rdr["ID"]); item.NAME = CommonTypeConvert.ToString(rdr["NAME"]); item.AMOUNT_DUE = CommonTypeConvert.ToDecimal(rdr["AMOUNT_DUE"]); item.AMOUNT_DUE_USDOLLAR = CommonTypeConvert.ToDecimal(rdr["AMOUNT_DUE_USDOLLAR"]); if (gCURRENCY_ID != CommonTypeConvert.ToGuid(rdr["CURRENCY_ID"])) { Currency C10n = Currency.CreateCurrency(gCURRENCY_ID); item.AMOUNT_DUE = Currency.GetCurrency.ToCurrency(item.AMOUNT_DUE_USDOLLAR); } } } if (CommonTypeConvert.IsEmptyGuid(item.ID)) throw (new Exception("Item not found")); } return item; }
private void UpdateContact(Guid gCONTACT_ID, bool bUpdateBilling, bool bUpdateShipping) { string innerSql = ApplicationSQL.SQL["Invoices_EditView_267"].ToString(); var oQuery = new InlineQueryDBManager(); oQuery.CommandText = innerSql; oQuery.Add("@ID", SqlDbType.UniqueIdentifier, gCONTACT_ID); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { if (bUpdateBilling) { new DynamicControl(this, "BILLING_CONTACT_ID").ID = CommonTypeConvert.ToGuid(rdr["ID"]); new DynamicControl(this, "BILLING_CONTACT_NAME").Text = CommonTypeConvert.ToString(rdr["NAME"]); } if (bUpdateShipping) { new DynamicControl(this, "SHIPPING_CONTACT_ID").ID = CommonTypeConvert.ToGuid(rdr["ID"]); new DynamicControl(this, "SHIPPING_CONTACT_NAME").Text = CommonTypeConvert.ToString(rdr["NAME"]); } Guid gACCOUNT_ID = CommonTypeConvert.ToGuid(rdr["ACCOUNT_ID"]); if (!CommonTypeConvert.IsEmptyGuid(gACCOUNT_ID)) { UpdateAccount(gACCOUNT_ID, bUpdateBilling, bUpdateShipping); } } } }
protected void Page_Command(object sender, CommandEventArgs e) { if (e.CommandName == "Refund") { Guid gPAYMENTS_TRANSACTION_ID = CommonTypeConvert.ToGuid(e.CommandArgument); var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["PaymentTransactions"].ToString(); oQuery.CommandText = innerSql; TypeConvert.AppendParameter(oQuery, gPAYMENTS_TRANSACTION_ID, "ID", false); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { Guid gCURRENCY_ID = CommonTypeConvert.ToGuid(rdr["CURRENCY_ID"]); Guid gACCOUNT_ID = CommonTypeConvert.ToGuid(rdr["ACCOUNT_ID"]); Guid gCREDIT_CARD_ID = CommonTypeConvert.ToGuid(rdr["CREDIT_CARD_ID"]); string sINVOICE_NUMBER = CommonTypeConvert.ToString(rdr["INVOICE_NUMBER"]); Decimal dAMOUNT = CommonTypeConvert.ToDecimal(rdr["AMOUNT"]); string sDESCRIPTION = CommonTypeConvert.ToString(rdr["DESCRIPTION"]); string sTRANSACTION_NUMBER = CommonTypeConvert.ToString(rdr["TRANSACTION_NUMBER"]); //CRM.Common.Charge.CC.Refund(Application, gID, gCURRENCY_ID, gACCOUNT_ID, gCREDIT_CARD_ID, Request.UserHostAddress, sINVOICE_NUMBER, sDESCRIPTION, dAMOUNT, sTRANSACTION_NUMBER); BindGrid(); } } } }
protected void btnProductChanged_Clicked(object sender, EventArgs e) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Products_EditView_161"].ToString(); oQuery.CommandText = innerSql; Guid gPRODUCT_TEMPLATE_ID = new DynamicControl(this, "PRODUCT_TEMPLATE_ID").ID; TypeConvert.AppendParameter(oQuery, gPRODUCT_TEMPLATE_ID, "ID", false); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; CRMDynamic.SetEditViewFields(this, m_sMODULE + ".EditView", rdr); CRMDynamic.SetEditViewFields(this, m_sMODULE + ".CostView", rdr); CRMDynamic.SetEditViewFields(this, m_sMODULE + ".MftView", rdr); var txtNAME = FindControl("NAME") as TextBox; if (txtNAME != null) { txtNAME.ReadOnly = false; } } } }
protected void PAYMENT_TYPE_Changed(object sender, EventArgs e) { var PAYMENT_TYPE = tblMain.FindControl("PAYMENT_TYPE") as DropDownList; if (PAYMENT_TYPE != null) { bool bCreditCard = PAYMENT_TYPE.SelectedValue == "Credit Card"; ctlDynamicButtons.ShowButton("Charge", bCreditCard); new DynamicControl(this, "CREDIT_CARD_ID_LABEL").Visible = bCreditCard; new DynamicControl(this, "CREDIT_CARD_NAME").Visible = bCreditCard; new DynamicControl(this, "CREDIT_CARD_ID_btnChange").Visible = bCreditCard; new DynamicControl(this, "CREDIT_CARD_ID_btnClear").Visible = bCreditCard; if (bCreditCard && CommonTypeConvert.IsEmptyGuid(new DynamicControl(this, "CREDIT_CARD_ID").ID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Payments_EditView_214"].ToString(); oQuery.CommandText = innerSql; Guid gACCOUNT_ID = new DynamicControl(this, "ACCOUNT_ID").ID; TypeConvert.AppendParameter(oQuery, gACCOUNT_ID, "ACCOUNT_ID", false); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { new DynamicControl(this, "CREDIT_CARD_ID").ID = CommonTypeConvert.ToGuid(rdr["ID"]); new DynamicControl(this, "CREDIT_CARD_NAME").Text = CommonTypeConvert.ToString(rdr["NAME"]); } } } } }
protected void btnProductChanged_Clicked(object sender, EventArgs e) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Products_EditView_161"].ToString(); oQuery.CommandText = innerSql; Guid gPRODUCT_TEMPLATE_ID = new DynamicControl(this, "PRODUCT_TEMPLATE_ID").ID; TypeConvert.AppendParameter(oQuery, gPRODUCT_TEMPLATE_ID, "ID", false); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; CRMDynamic.SetEditViewFields(this, m_sMODULE + ".EditView", rdr); CRMDynamic.SetEditViewFields(this, m_sMODULE + ".CostView", rdr); CRMDynamic.SetEditViewFields(this, m_sMODULE + ".MftView", rdr); var txtNAME = FindControl("NAME") as TextBox; if (txtNAME != null) txtNAME.ReadOnly = false; } } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!Visible) { return; } gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); Guid gDuplicateID = CommonTypeConvert.ToGuid(Request["DuplicateID"]); if (!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Administration_ProductTemplates_EditView"].ToString(); oQuery.CommandText = innerSql; if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { oQuery.Add("@ID", SqlDbType.UniqueIdentifier, gDuplicateID); gID = Guid.Empty; } else { oQuery.Add("@ID", SqlDbType.UniqueIdentifier, gID); } using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); } } } else { AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); } } else { ctlModuleHeader.Title = CommonTypeConvert.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "view") >= 0); if (!Visible) { return; } gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { if (!CommonTypeConvert.IsEmptyGuid(gID)) { string innerSql = ApplicationSQL.SQL["Invoices_EditView_323"].ToString(); var oQuery = new InlineQueryDBManager(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, m_sMODULE, "view"); TypeConvert.AppendParameter(oQuery, gID, "ID", false); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); AppendDetailViewFields(m_sMODULE + ".DetailView", tblMain, rdr, Page_Command); AppendDetailViewFields(m_sMODULE + ".SummaryView", tblSummary, rdr, Page_Command); Page.Items["ASSIGNED_USER_ID"] = CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]); ctlDynamicButtons.AppendButtons(m_sMODULE + ".DetailView", CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]), rdr); } else { plcSubPanel.Visible = false; ctlDynamicButtons.AppendButtons(m_sMODULE + ".DetailView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("ACL.LBL_NO_ACCESS"); } } } else { ctlDynamicButtons.AppendButtons(m_sMODULE + ".DetailView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); } } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "view") >= 0); if (!Visible) return; gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { if (!CommonTypeConvert.IsEmptyGuid(gID)) { string innerSql = ApplicationSQL.SQL["Invoices_EditView_323"].ToString(); var oQuery = new InlineQueryDBManager(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, m_sMODULE, "view"); TypeConvert.AppendParameter(oQuery, gID, "ID", false); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); AppendDetailViewFields(m_sMODULE + ".DetailView", tblMain, rdr, Page_Command); AppendDetailViewFields(m_sMODULE + ".SummaryView", tblSummary, rdr, Page_Command); Page.Items["ASSIGNED_USER_ID"] = CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]); ctlDynamicButtons.AppendButtons(m_sMODULE + ".DetailView", CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]), rdr); } else { plcSubPanel.Visible = false; ctlDynamicButtons.AppendButtons(m_sMODULE + ".DetailView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("ACL.LBL_NO_ACCESS"); } } } else { ctlDynamicButtons.AppendButtons(m_sMODULE + ".DetailView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); } } }
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(); } } }
public LineItem GetItemDetailsByNumber(Guid gCURRENCY_ID, string sMFT_PART_NUM) { var item = new LineItem(); { if (Security.USER_ID == Guid.Empty) { throw (new Exception("Authentication required")); } var oQuery = new InlineQueryDBManager(); oQuery.CommandText = ApplicationSQL.SQL["ProductCatalog_AutoComplete_63"].ToString(); CRMSecurity.Filter(oQuery, "ProductTemplates", "list"); TypeConvert.AppendParameter(oQuery, sMFT_PART_NUM, CommonTypeConvert.SqlFilterMode.StartsWith, "MFT_PART_NUM"); oQuery.CommandText += " order by MFT_PART_NUM" + ControlChars.CrLf; using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { item.ID = CommonTypeConvert.ToGuid(rdr["ID"]); item.NAME = CommonTypeConvert.ToString(rdr["NAME"]); item.MFT_PART_NUM = CommonTypeConvert.ToString(rdr["MFT_PART_NUM"]); item.VENDOR_PART_NUM = CommonTypeConvert.ToString(rdr["VENDOR_PART_NUM"]); item.TAX_CLASS = CommonTypeConvert.ToString(rdr["TAX_CLASS"]); item.COST_PRICE = CommonTypeConvert.ToDecimal(rdr["COST_PRICE"]); item.COST_USDOLLAR = CommonTypeConvert.ToDecimal(rdr["COST_USDOLLAR"]); item.LIST_PRICE = CommonTypeConvert.ToDecimal(rdr["LIST_PRICE"]); item.LIST_USDOLLAR = CommonTypeConvert.ToDecimal(rdr["LIST_USDOLLAR"]); item.UNIT_PRICE = CommonTypeConvert.ToDecimal(rdr["UNIT_PRICE"]); item.UNIT_USDOLLAR = CommonTypeConvert.ToDecimal(rdr["UNIT_USDOLLAR"]); if (gCURRENCY_ID != CommonTypeConvert.ToGuid(rdr["CURRENCY_ID"])) { Currency C10n = Currency.CreateCurrency(gCURRENCY_ID); item.COST_PRICE = Currency.GetCurrency.ToCurrency(item.COST_USDOLLAR); item.LIST_PRICE = Currency.GetCurrency.ToCurrency(item.LIST_USDOLLAR); item.UNIT_PRICE = Currency.GetCurrency.ToCurrency(item.UNIT_USDOLLAR); } } } if (CommonTypeConvert.IsEmptyGuid(item.ID)) { throw (new Exception("Item not found")); } } return(item); }
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(); } } }
private void UpdateAccount(Guid gACCOUNT_ID, bool bUpdateBilling, bool bUpdateShipping) { string innerSql = ApplicationSQL.SQL["Invoices_EditView_223"].ToString(); var oQuery = new InlineQueryDBManager(); oQuery.CommandText = innerSql; oQuery.Add("@ID", SqlDbType.UniqueIdentifier, gACCOUNT_ID); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { if (bUpdateBilling) { new DynamicControl(this, "BILLING_ACCOUNT_ID").ID = CommonTypeConvert.ToGuid(rdr["ID"]); new DynamicControl(this, "BILLING_ACCOUNT_NAME").Text = CommonTypeConvert.ToString(rdr["NAME"]); new DynamicControl(this, "BILLING_ADDRESS_STREET").Text = CommonTypeConvert.ToString(rdr["BILLING_ADDRESS_STREET"]); new DynamicControl(this, "BILLING_ADDRESS_CITY").Text = CommonTypeConvert.ToString(rdr["BILLING_ADDRESS_CITY"]); new DynamicControl(this, "BILLING_ADDRESS_STATE").Text = CommonTypeConvert.ToString(rdr["BILLING_ADDRESS_STATE"]); new DynamicControl(this, "BILLING_ADDRESS_POSTALCODE").Text = CommonTypeConvert.ToString(rdr["BILLING_ADDRESS_POSTALCODE"]); new DynamicControl(this, "BILLING_ADDRESS_COUNTRY").Text = CommonTypeConvert.ToString(rdr["BILLING_ADDRESS_COUNTRY"]); } if (bUpdateShipping) { new DynamicControl(this, "SHIPPING_ACCOUNT_ID").ID = CommonTypeConvert.ToGuid(rdr["ID"]); new DynamicControl(this, "SHIPPING_ACCOUNT_NAME").Text = CommonTypeConvert.ToString(rdr["NAME"]); new DynamicControl(this, "SHIPPING_ADDRESS_STREET").Text = CommonTypeConvert.ToString(rdr["SHIPPING_ADDRESS_STREET"]); new DynamicControl(this, "SHIPPING_ADDRESS_CITY").Text = CommonTypeConvert.ToString(rdr["SHIPPING_ADDRESS_CITY"]); new DynamicControl(this, "SHIPPING_ADDRESS_STATE").Text = CommonTypeConvert.ToString(rdr["SHIPPING_ADDRESS_STATE"]); new DynamicControl(this, "SHIPPING_ADDRESS_POSTALCODE").Text = CommonTypeConvert.ToString(rdr["SHIPPING_ADDRESS_POSTALCODE"]); new DynamicControl(this, "SHIPPING_ADDRESS_COUNTRY").Text = CommonTypeConvert.ToString(rdr["SHIPPING_ADDRESS_COUNTRY"]); } } } }
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_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(); } } }
public Invoice GetInvoiceByName(Guid gCURRENCY_ID, string sNAME) { var item = new Invoice(); { if (Security.USER_ID == Guid.Empty) { throw (new Exception("Authentication required")); } var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Invoices_AutoComplete_50"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, "Invoices", "list"); TypeConvert.AppendParameter(oQuery, sNAME, CommonTypeConvert.SqlFilterMode.StartsWith, "NAME"); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { item.ID = CommonTypeConvert.ToGuid(rdr["ID"]); item.NAME = CommonTypeConvert.ToString(rdr["NAME"]); item.AMOUNT_DUE = CommonTypeConvert.ToDecimal(rdr["AMOUNT_DUE"]); item.AMOUNT_DUE_USDOLLAR = CommonTypeConvert.ToDecimal(rdr["AMOUNT_DUE_USDOLLAR"]); if (gCURRENCY_ID != CommonTypeConvert.ToGuid(rdr["CURRENCY_ID"])) { Currency C10n = Currency.CreateCurrency(gCURRENCY_ID); item.AMOUNT_DUE = Currency.GetCurrency.ToCurrency(item.AMOUNT_DUE_USDOLLAR); } } } if (CommonTypeConvert.IsEmptyGuid(item.ID)) { throw (new Exception("Item not found")); } } return(item); }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!Visible) { return; } gID = CommonTypeConvert.ToGuid(Request["ID"]); if (CommonTypeConvert.IsEmptyGuid(gID)) { gID = CommonTypeConvert.ToGuid(ViewState["ID"]); } if (!IsPostBack) { Guid gDuplicateID = CommonTypeConvert.ToGuid(Request["DuplicateID"]); if (!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Payments_EditView_259"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, m_sMODULE, "edit"); if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { TypeConvert.AppendParameter(oQuery, gDuplicateID, "ID", false); gID = Guid.Empty; } else { TypeConvert.AppendParameter(oQuery, gID, "ID", false); } using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["PAYMENT_NUM"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]), rdr); var CURRENCY_ID = tblMain.FindControl("CURRENCY_ID") as DropDownList; if (CURRENCY_ID != null) { CURRENCY_ID.AutoPostBack = true; CURRENCY_ID.SelectedIndexChanged += CURRENCY_ID_Changed; } var PAYMENT_TYPE = tblMain.FindControl("PAYMENT_TYPE") as DropDownList; if (PAYMENT_TYPE != null) { PAYMENT_TYPE.AutoPostBack = true; PAYMENT_TYPE.SelectedIndexChanged += PAYMENT_TYPE_Changed; PAYMENT_TYPE_Changed(null, null); } Guid gACCOUNT_ID = CommonTypeConvert.ToGuid(rdr["ACCOUNT_ID"]); ctlAllocationsView.LoadLineItems(gID, gACCOUNT_ID, gDuplicateID, oQuery, rdr); } else { Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); ctlAllocationsView.LoadLineItems(gID, gPARENT_ID, gDuplicateID, oQuery, null); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("ACL.LBL_NO_ACCESS"); } } } else { AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); var CURRENCY_ID = tblMain.FindControl("CURRENCY_ID") as DropDownList; if (CURRENCY_ID != null) { CURRENCY_ID.AutoPostBack = true; CURRENCY_ID.SelectedIndexChanged += CURRENCY_ID_Changed; } Guid gACCOUNT_ID = Guid.Empty; Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); new DynamicControl(this, "PAYMENT_DATE").DateValue = DateTime.Today; Guid gINVOICE_ID = gPARENT_ID; if (!CommonTypeConvert.IsEmptyGuid(gPARENT_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 (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts") { gACCOUNT_ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_ID").ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME; var oQuery = new InlineQueryDBManager(); ctlAllocationsView.LoadLineItems(gID, gACCOUNT_ID, gDuplicateID, oQuery, null); } else if (!CommonTypeConvert.IsEmptyGuid(gINVOICE_ID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Payments_EditView"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, "Invoices", "edit"); TypeConvert.AppendParameter(oQuery, gINVOICE_ID, "ID", false); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { gACCOUNT_ID = CommonTypeConvert.ToGuid(rdr["BILLING_ACCOUNT_ID"]); new DynamicControl(this, "ACCOUNT_ID").ID = CommonTypeConvert.ToGuid(rdr["BILLING_ACCOUNT_ID"]); new DynamicControl(this, "ACCOUNT_NAME").Text = CommonTypeConvert.ToString(rdr["BILLING_ACCOUNT_NAME"]); ctlAllocationsView.LoadLineItems(gID, gACCOUNT_ID, gDuplicateID, oQuery, null); new DynamicControl(this, "AMOUNT").Text = Currency.GetCurrency.ToCurrency( CommonTypeConvert.ToDecimal(rdr["AMOUNT_DUE_USDOLLAR"])).ToString("0.00"); } } } } var PAYMENT_TYPE = tblMain.FindControl("PAYMENT_TYPE") as DropDownList; if (PAYMENT_TYPE != null) { PAYMENT_TYPE.AutoPostBack = true; PAYMENT_TYPE.SelectedIndexChanged += PAYMENT_TYPE_Changed; PAYMENT_TYPE_Changed(null, null); } } } else { ctlModuleHeader.Title = CommonTypeConvert.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!Visible) return; gID = CommonTypeConvert.ToGuid(Request["ID"]); if (CommonTypeConvert.IsEmptyGuid(gID)) gID = CommonTypeConvert.ToGuid(ViewState["ID"]); if (!IsPostBack) { Guid gDuplicateID = CommonTypeConvert.ToGuid(Request["DuplicateID"]); if (!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Payments_EditView_259"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, m_sMODULE, "edit"); if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { TypeConvert.AppendParameter(oQuery, gDuplicateID, "ID", false); gID = Guid.Empty; } else { TypeConvert.AppendParameter(oQuery, gID, "ID", false); } using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["PAYMENT_NUM"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]), rdr); var CURRENCY_ID = tblMain.FindControl("CURRENCY_ID") as DropDownList; if (CURRENCY_ID != null) { CURRENCY_ID.AutoPostBack = true; CURRENCY_ID.SelectedIndexChanged += CURRENCY_ID_Changed; } var PAYMENT_TYPE = tblMain.FindControl("PAYMENT_TYPE") as DropDownList; if (PAYMENT_TYPE != null) { PAYMENT_TYPE.AutoPostBack = true; PAYMENT_TYPE.SelectedIndexChanged += PAYMENT_TYPE_Changed; PAYMENT_TYPE_Changed(null, null); } Guid gACCOUNT_ID = CommonTypeConvert.ToGuid(rdr["ACCOUNT_ID"]); ctlAllocationsView.LoadLineItems(gID, gACCOUNT_ID, gDuplicateID, oQuery, rdr); } else { Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); ctlAllocationsView.LoadLineItems(gID, gPARENT_ID, gDuplicateID, oQuery, null); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("ACL.LBL_NO_ACCESS"); } } } else { AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); var CURRENCY_ID = tblMain.FindControl("CURRENCY_ID") as DropDownList; if (CURRENCY_ID != null) { CURRENCY_ID.AutoPostBack = true; CURRENCY_ID.SelectedIndexChanged += CURRENCY_ID_Changed; } Guid gACCOUNT_ID = Guid.Empty; Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); new DynamicControl(this, "PAYMENT_DATE").DateValue = DateTime.Today; Guid gINVOICE_ID = gPARENT_ID; if (!CommonTypeConvert.IsEmptyGuid(gPARENT_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 (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts") { gACCOUNT_ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_ID").ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME; var oQuery = new InlineQueryDBManager(); ctlAllocationsView.LoadLineItems(gID, gACCOUNT_ID, gDuplicateID, oQuery, null); } else if (!CommonTypeConvert.IsEmptyGuid(gINVOICE_ID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Payments_EditView"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, "Invoices", "edit"); TypeConvert.AppendParameter(oQuery, gINVOICE_ID, "ID", false); using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { gACCOUNT_ID = CommonTypeConvert.ToGuid(rdr["BILLING_ACCOUNT_ID"]); new DynamicControl(this, "ACCOUNT_ID").ID = CommonTypeConvert.ToGuid(rdr["BILLING_ACCOUNT_ID"]); new DynamicControl(this, "ACCOUNT_NAME").Text = CommonTypeConvert.ToString(rdr["BILLING_ACCOUNT_NAME"]); ctlAllocationsView.LoadLineItems(gID, gACCOUNT_ID, gDuplicateID, oQuery, null); new DynamicControl(this, "AMOUNT").Text = Currency.GetCurrency.ToCurrency( CommonTypeConvert.ToDecimal(rdr["AMOUNT_DUE_USDOLLAR"])).ToString("0.00"); } } } } var PAYMENT_TYPE = tblMain.FindControl("PAYMENT_TYPE") as DropDownList; if (PAYMENT_TYPE != null) { PAYMENT_TYPE.AutoPostBack = true; PAYMENT_TYPE.SelectedIndexChanged += PAYMENT_TYPE_Changed; PAYMENT_TYPE_Changed(null, null); } } } else { ctlModuleHeader.Title = CommonTypeConvert.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } }
public void LoadLineItems(Guid gID, Guid gACCOUNT_ID, Guid gDuplicateID, InlineQueryDBManager oQuery, SqlDataReader rdr) { this.gACCOUNT_ID = gACCOUNT_ID; if (!IsPostBack) { GetCurrencyControl(); CURRENCY_ID.SelectedValue = Currency.GetCurrency.ID.ToString(); EXCHANGE_RATE.Value = Currency.GetCurrency.CONVERSION_RATE.ToString(); foreach (DataControlField col in grdMain.Columns) { if (!CommonTypeConvert.IsEmptyString(col.HeaderText)) { col.HeaderText = Translation.GetTranslation.Term(col.HeaderText); } var cf = col as CommandField; if (cf != null) { cf.EditText = Translation.GetTranslation.Term(cf.EditText); cf.DeleteText = Translation.GetTranslation.Term(cf.DeleteText); cf.UpdateText = Translation.GetTranslation.Term(cf.UpdateText); cf.CancelText = Translation.GetTranslation.Term(cf.CancelText); } } if ((!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID)) && (oQuery != null) && (rdr != null)) { CURRENCY_ID.SelectedValue = CommonTypeConvert.ToString(rdr["CURRENCY_ID"]); EXCHANGE_RATE.Value = Currency.GetCurrency.CONVERSION_RATE.ToString(); float fEXCHANGE_RATE = CommonTypeConvert.ToFloat(rdr["EXCHANGE_RATE"]); if (fEXCHANGE_RATE == 0.0f) fEXCHANGE_RATE = 1.0f; EXCHANGE_RATE.Value = fEXCHANGE_RATE.ToString(); if (CURRENCY_ID.Items.Count > 0) { Guid gCURRENCY_ID = CommonTypeConvert.ToGuid(CURRENCY_ID.SelectedValue); SetCurrency(gCURRENCY_ID, fEXCHANGE_RATE); EXCHANGE_RATE.Value = Currency.GetCurrency.CONVERSION_RATE.ToString(); } ALLOCATED.Text = Currency.GetCurrency.ToCurrency(CommonTypeConvert.ToDecimal(rdr["TOTAL_ALLOCATED_USDOLLAR"])). ToString("c"); ALLOCATED_USDOLLAR.Value = CommonTypeConvert.ToDecimal(rdr["TOTAL_ALLOCATED_USDOLLAR"]).ToString("0.00"); rdr.Close(); string innerSql = ApplicationSQL.SQL["Payments_AllocationsView_233"].ToString(); oQuery.CommandText = innerSql; TypeConvert.AppendParameter(oQuery, gID, "PAYMENT_ID", false); oQuery.CommandText += " order by DATE_MODIFIED asc" + ControlChars.CrLf; DataTable dtLineItems = oQuery.GetTable(); if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { foreach (DataRow row in dtLineItems.Rows) { row["ID"] = Guid.NewGuid(); } } DataRow rowNew = dtLineItems.NewRow(); dtLineItems.Rows.Add(rowNew); ViewState["LineItems"] = dtLineItems; grdMain.DataSource = dtLineItems; grdMain.EditIndex = dtLineItems.Rows.Count - 1; grdMain.DataBind(); } else { dtLineItems = new DataTable(); var colID = new DataColumn("ID", Type.GetType("System.Guid")); var colINVOICE_NAME = new DataColumn("INVOICE_NAME", Type.GetType("System.String")); var colINVOICE_ID = new DataColumn("INVOICE_ID", Type.GetType("System.Guid")); var colAMOUNT_DUE = new DataColumn("AMOUNT_DUE", Type.GetType("System.Decimal")); var colAMOUNT_DUE_USDOLLAR = new DataColumn("AMOUNT_DUE_USDOLLAR", Type.GetType("System.Decimal")); var colAMOUNT = new DataColumn("AMOUNT", Type.GetType("System.Decimal")); var colAMOUNT_USDOLLAR = new DataColumn("AMOUNT_USDOLLAR", Type.GetType("System.Decimal")); dtLineItems.Columns.Add(colID); dtLineItems.Columns.Add(colINVOICE_NAME); dtLineItems.Columns.Add(colINVOICE_ID); dtLineItems.Columns.Add(colAMOUNT_DUE); dtLineItems.Columns.Add(colAMOUNT_DUE_USDOLLAR); dtLineItems.Columns.Add(colAMOUNT); dtLineItems.Columns.Add(colAMOUNT_USDOLLAR); DataRow rowNew = null; string innerSql = ApplicationSQL.SQL["Payments_AllocationsView"].ToString(); oQuery.CommandText = innerSql; Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); TypeConvert.AppendParameter(oQuery, gPARENT_ID, "ID", false); using (SqlDataReader rdrInvoice = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdrInvoice.Read()) { rowNew = dtLineItems.NewRow(); rowNew["INVOICE_NAME"] = CommonTypeConvert.ToString(rdrInvoice["NAME"]); rowNew["INVOICE_ID"] = CommonTypeConvert.ToGuid(rdrInvoice["ID"]); rowNew["AMOUNT_DUE"] = CommonTypeConvert.ToDecimal(rdrInvoice["AMOUNT_DUE"]); rowNew["AMOUNT_DUE_USDOLLAR"] = CommonTypeConvert.ToDecimal(rdrInvoice["AMOUNT_DUE_USDOLLAR"]); rowNew["AMOUNT"] = CommonTypeConvert.ToDecimal(rdrInvoice["AMOUNT_DUE"]); rowNew["AMOUNT_USDOLLAR"] = CommonTypeConvert.ToDecimal(rdrInvoice["AMOUNT_DUE_USDOLLAR"]); if (rdrInvoice["AMOUNT_DUE"] == DBNull.Value) { rowNew["AMOUNT_DUE"] = CommonTypeConvert.ToDecimal(rdrInvoice["TOTAL"]); rowNew["AMOUNT_DUE_USDOLLAR"] = CommonTypeConvert.ToDecimal(rdrInvoice["TOTAL_USDOLLAR"]); rowNew["AMOUNT"] = CommonTypeConvert.ToDecimal(rdrInvoice["TOTAL"]); rowNew["AMOUNT_USDOLLAR"] = CommonTypeConvert.ToDecimal(rdrInvoice["TOTAL_USDOLLAR"]); } dtLineItems.Rows.Add(rowNew); } } rowNew = dtLineItems.NewRow(); dtLineItems.Rows.Add(rowNew); ViewState["LineItems"] = dtLineItems; grdMain.DataSource = dtLineItems; grdMain.EditIndex = dtLineItems.Rows.Count - 1; grdMain.DataBind(); UpdateTotals(); } } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!Visible) return; gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { string sLOAD_MODULE = "Invoices"; string sLOAD_MODULE_KEY = "INVOICE_ID"; Guid gQUOTE_ID = CommonTypeConvert.ToGuid(Request["QUOTE_ID"]); Guid gORDER_ID = CommonTypeConvert.ToGuid(Request["ORDER_ID"]); Guid gDuplicateID = CommonTypeConvert.ToGuid(Request["DuplicateID"]); if (!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID) || !CommonTypeConvert.IsEmptyGuid(gQUOTE_ID) || !CommonTypeConvert.IsEmptyGuid(gORDER_ID)) { string innerSql = ApplicationSQL.SQL["Invoices_EditView_323"].ToString(); var oQuery = new InlineQueryDBManager(); oQuery.CommandText = innerSql; if (!CommonTypeConvert.IsEmptyGuid(gQUOTE_ID)) { //Load the data from the QUOTES record. sLOAD_MODULE = "Quotes"; sLOAD_MODULE_KEY = "QUOTE_ID"; innerSql = ApplicationSQL.SQL["Invoices_EditView_333"].ToString(); oQuery.CommandText = innerSql; //Filter by the module we are loading. CRMSecurity.Filter(oQuery, sLOAD_MODULE, "edit"); TypeConvert.AppendParameter(oQuery, gQUOTE_ID, "ID", false); } else if (!CommonTypeConvert.IsEmptyGuid(gORDER_ID)) { // Load the data from the ORDERS record. sLOAD_MODULE = "Orders"; sLOAD_MODULE_KEY = "ORDER_ID"; innerSql = ApplicationSQL.SQL["Invoices_EditView"].ToString(); oQuery.CommandText = innerSql; //Filter by the module we are loading. CRMSecurity.Filter(oQuery, sLOAD_MODULE, "edit"); TypeConvert.AppendParameter(oQuery, gORDER_ID, "ID", false); } else { //Use new CRMSecurity.Filter() function to apply Team and ACL security rules. CRMSecurity.Filter(oQuery, m_sMODULE, "edit"); if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { TypeConvert.AppendParameter(oQuery, gDuplicateID, "ID", false); gID = Guid.Empty; } else { TypeConvert.AppendParameter(oQuery, gID, "ID", false); } } using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; ViewState["BILLING_ACCOUNT_ID"] = CommonTypeConvert.ToGuid(rdr["BILLING_ACCOUNT_ID"]); ViewState["SHIPPING_ACCOUNT_ID"] = CommonTypeConvert.ToGuid(rdr["SHIPPING_ACCOUNT_ID"]); new DynamicControl(this, "QUOTE_ID").ID = CommonTypeConvert.ToGuid(rdr["QUOTE_ID"]); new DynamicControl(this, "ORDER_ID").ID = CommonTypeConvert.ToGuid(rdr["ORDER_ID"]); AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, rdr); AppendEditViewFields(m_sMODULE + ".EditDescription", tblDescription, rdr); //Dynamic buttons need to be recreated in order for events to fire. ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]), rdr); if (!CommonTypeConvert.IsEmptyGuid(gQUOTE_ID)) { new DynamicControl(this, "QUOTE_ID").ID = gQUOTE_ID; new DynamicControl(this, "QUOTE_NAME").Text = CommonTypeConvert.ToString(rdr["NAME"]); ctlEditLineItemsView.LoadLineItems(gQUOTE_ID, Guid.Empty, rdr, sLOAD_MODULE, sLOAD_MODULE_KEY); } else if (!CommonTypeConvert.IsEmptyGuid(gORDER_ID)) { new DynamicControl(this, "ORDER_ID").ID = gORDER_ID; new DynamicControl(this, "ORDER_NAME").Text = CommonTypeConvert.ToString(rdr["NAME"]); ctlEditLineItemsView.LoadLineItems(gORDER_ID, Guid.Empty, rdr, sLOAD_MODULE, sLOAD_MODULE_KEY); } else { ctlEditLineItemsView.LoadLineItems(gID, gDuplicateID, rdr, sLOAD_MODULE, sLOAD_MODULE_KEY); } } else { ctlEditLineItemsView.LoadLineItems(gID, gDuplicateID, null, String.Empty, String.Empty); //If item is not visible, then don't allow save //Dynamic buttons need to be recreated in order for events to fire. ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("ACL.LBL_NO_ACCESS"); } } } else { AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, null); AppendEditViewFields(m_sMODULE + ".EditDescription", tblDescription, null); //Dynamic buttons need to be recreated in order for events to fire. ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); //Prepopulate the Account. Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); if (!CommonTypeConvert.IsEmptyGuid(gPARENT_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 (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts") { UpdateAccount(gPARENT_ID, true, true); } if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts") { UpdateContact(gPARENT_ID, true, true); } else if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Opportunities") { new DynamicControl(this, "OPPORTUNITY_ID").ID = gPARENT_ID; new DynamicControl(this, "OPPORTUNITY_NAME").Text = sPARENT_NAME; } } ctlEditLineItemsView.LoadLineItems(gID, gDuplicateID, new InlineQueryDBManager(), null, String.Empty, String.Empty); } } else { // When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = CommonTypeConvert.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); var ctlBILLING_ACCOUNT_ID = new DynamicControl(this, "BILLING_ACCOUNT_ID"); var ctlSHIPPING_ACCOUNT_ID = new DynamicControl(this, "SHIPPING_ACCOUNT_ID"); if (CommonTypeConvert.ToGuid(ViewState["BILLING_ACCOUNT_ID"]) != ctlBILLING_ACCOUNT_ID.ID) { UpdateAccount(ctlBILLING_ACCOUNT_ID.ID, true, true); ViewState["BILLING_ACCOUNT_ID"] = ctlBILLING_ACCOUNT_ID.ID; ViewState["SHIPPING_ACCOUNT_ID"] = ctlBILLING_ACCOUNT_ID.ID; } if (CommonTypeConvert.ToGuid(ViewState["SHIPPING_ACCOUNT_ID"]) != ctlSHIPPING_ACCOUNT_ID.ID) { UpdateAccount(ctlSHIPPING_ACCOUNT_ID.ID, false, true); ViewState["SHIPPING_ACCOUNT_ID"] = ctlSHIPPING_ACCOUNT_ID.ID; } } }
public void LoadLineItems(Guid gID, Guid gACCOUNT_ID, Guid gDuplicateID, InlineQueryDBManager oQuery, SqlDataReader rdr) { this.gACCOUNT_ID = gACCOUNT_ID; if (!IsPostBack) { GetCurrencyControl(); CURRENCY_ID.SelectedValue = Currency.GetCurrency.ID.ToString(); EXCHANGE_RATE.Value = Currency.GetCurrency.CONVERSION_RATE.ToString(); foreach (DataControlField col in grdMain.Columns) { if (!CommonTypeConvert.IsEmptyString(col.HeaderText)) { col.HeaderText = Translation.GetTranslation.Term(col.HeaderText); } var cf = col as CommandField; if (cf != null) { cf.EditText = Translation.GetTranslation.Term(cf.EditText); cf.DeleteText = Translation.GetTranslation.Term(cf.DeleteText); cf.UpdateText = Translation.GetTranslation.Term(cf.UpdateText); cf.CancelText = Translation.GetTranslation.Term(cf.CancelText); } } if ((!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID)) && (oQuery != null) && (rdr != null)) { CURRENCY_ID.SelectedValue = CommonTypeConvert.ToString(rdr["CURRENCY_ID"]); EXCHANGE_RATE.Value = Currency.GetCurrency.CONVERSION_RATE.ToString(); float fEXCHANGE_RATE = CommonTypeConvert.ToFloat(rdr["EXCHANGE_RATE"]); if (fEXCHANGE_RATE == 0.0f) { fEXCHANGE_RATE = 1.0f; } EXCHANGE_RATE.Value = fEXCHANGE_RATE.ToString(); if (CURRENCY_ID.Items.Count > 0) { Guid gCURRENCY_ID = CommonTypeConvert.ToGuid(CURRENCY_ID.SelectedValue); SetCurrency(gCURRENCY_ID, fEXCHANGE_RATE); EXCHANGE_RATE.Value = Currency.GetCurrency.CONVERSION_RATE.ToString(); } ALLOCATED.Text = Currency.GetCurrency.ToCurrency(CommonTypeConvert.ToDecimal(rdr["TOTAL_ALLOCATED_USDOLLAR"])). ToString("c"); ALLOCATED_USDOLLAR.Value = CommonTypeConvert.ToDecimal(rdr["TOTAL_ALLOCATED_USDOLLAR"]).ToString("0.00"); rdr.Close(); string innerSql = ApplicationSQL.SQL["Payments_AllocationsView_233"].ToString(); oQuery.CommandText = innerSql; TypeConvert.AppendParameter(oQuery, gID, "PAYMENT_ID", false); oQuery.CommandText += " order by DATE_MODIFIED asc" + ControlChars.CrLf; DataTable dtLineItems = oQuery.GetTable(); if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { foreach (DataRow row in dtLineItems.Rows) { row["ID"] = Guid.NewGuid(); } } DataRow rowNew = dtLineItems.NewRow(); dtLineItems.Rows.Add(rowNew); ViewState["LineItems"] = dtLineItems; grdMain.DataSource = dtLineItems; grdMain.EditIndex = dtLineItems.Rows.Count - 1; grdMain.DataBind(); } else { dtLineItems = new DataTable(); var colID = new DataColumn("ID", Type.GetType("System.Guid")); var colINVOICE_NAME = new DataColumn("INVOICE_NAME", Type.GetType("System.String")); var colINVOICE_ID = new DataColumn("INVOICE_ID", Type.GetType("System.Guid")); var colAMOUNT_DUE = new DataColumn("AMOUNT_DUE", Type.GetType("System.Decimal")); var colAMOUNT_DUE_USDOLLAR = new DataColumn("AMOUNT_DUE_USDOLLAR", Type.GetType("System.Decimal")); var colAMOUNT = new DataColumn("AMOUNT", Type.GetType("System.Decimal")); var colAMOUNT_USDOLLAR = new DataColumn("AMOUNT_USDOLLAR", Type.GetType("System.Decimal")); dtLineItems.Columns.Add(colID); dtLineItems.Columns.Add(colINVOICE_NAME); dtLineItems.Columns.Add(colINVOICE_ID); dtLineItems.Columns.Add(colAMOUNT_DUE); dtLineItems.Columns.Add(colAMOUNT_DUE_USDOLLAR); dtLineItems.Columns.Add(colAMOUNT); dtLineItems.Columns.Add(colAMOUNT_USDOLLAR); DataRow rowNew = null; string innerSql = ApplicationSQL.SQL["Payments_AllocationsView"].ToString(); oQuery.CommandText = innerSql; Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); TypeConvert.AppendParameter(oQuery, gPARENT_ID, "ID", false); using (SqlDataReader rdrInvoice = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdrInvoice.Read()) { rowNew = dtLineItems.NewRow(); rowNew["INVOICE_NAME"] = CommonTypeConvert.ToString(rdrInvoice["NAME"]); rowNew["INVOICE_ID"] = CommonTypeConvert.ToGuid(rdrInvoice["ID"]); rowNew["AMOUNT_DUE"] = CommonTypeConvert.ToDecimal(rdrInvoice["AMOUNT_DUE"]); rowNew["AMOUNT_DUE_USDOLLAR"] = CommonTypeConvert.ToDecimal(rdrInvoice["AMOUNT_DUE_USDOLLAR"]); rowNew["AMOUNT"] = CommonTypeConvert.ToDecimal(rdrInvoice["AMOUNT_DUE"]); rowNew["AMOUNT_USDOLLAR"] = CommonTypeConvert.ToDecimal(rdrInvoice["AMOUNT_DUE_USDOLLAR"]); if (rdrInvoice["AMOUNT_DUE"] == DBNull.Value) { rowNew["AMOUNT_DUE"] = CommonTypeConvert.ToDecimal(rdrInvoice["TOTAL"]); rowNew["AMOUNT_DUE_USDOLLAR"] = CommonTypeConvert.ToDecimal(rdrInvoice["TOTAL_USDOLLAR"]); rowNew["AMOUNT"] = CommonTypeConvert.ToDecimal(rdrInvoice["TOTAL"]); rowNew["AMOUNT_USDOLLAR"] = CommonTypeConvert.ToDecimal(rdrInvoice["TOTAL_USDOLLAR"]); } dtLineItems.Rows.Add(rowNew); } } rowNew = dtLineItems.NewRow(); dtLineItems.Rows.Add(rowNew); ViewState["LineItems"] = dtLineItems; grdMain.DataSource = dtLineItems; grdMain.EditIndex = dtLineItems.Rows.Count - 1; grdMain.DataBind(); UpdateTotals(); } } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!Visible) return; gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); Guid gDuplicateID = CommonTypeConvert.ToGuid(Request["DuplicateID"]); if (!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Administration_ProductTemplates_EditView"].ToString(); oQuery.CommandText = innerSql; if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { oQuery.Add("@ID", SqlDbType.UniqueIdentifier, gDuplicateID); gID = Guid.Empty; } else { oQuery.Add("@ID", SqlDbType.UniqueIdentifier, gID); } using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); } } } else { AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); } } else { ctlModuleHeader.Title = CommonTypeConvert.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!Visible) { return; } gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { Guid gDuplicateID = CommonTypeConvert.ToGuid(Request["DuplicateID"]); if (!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Products_EditView"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, m_sMODULE, "edit"); if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { TypeConvert.AppendParameter(oQuery, gDuplicateID, "ID", false); gID = Guid.Empty; } else { TypeConvert.AppendParameter(oQuery, gID, "ID", false); } using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); AppendEditViewFields(m_sMODULE + ".CostView", tblCost, rdr); AppendEditViewFields(m_sMODULE + ".MftView", tblManufacturer, rdr); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]), rdr); var txtNAME = FindControl("NAME") as TextBox; if (txtNAME != null) { txtNAME.ReadOnly = false; } } else { ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("ACL.LBL_NO_ACCESS"); } } } else { AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); AppendEditViewFields(m_sMODULE + ".CostView", tblCost, null); AppendEditViewFields(m_sMODULE + ".MftView", tblManufacturer, null); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); var txtNAME = FindControl("NAME") as TextBox; if (txtNAME != null) { txtNAME.ReadOnly = false; } Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); if (!CommonTypeConvert.IsEmptyGuid(gPARENT_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 (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts") { new DynamicControl(this, "ACCOUNT_ID").ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME; } else if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts") { new DynamicControl(this, "CONTACT_ID").ID = gPARENT_ID; new DynamicControl(this, "CONTACT_NAME").Text = sPARENT_NAME; } } } } else { ctlModuleHeader.Title = CommonTypeConvert.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!Visible) { return; } gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { string sLOAD_MODULE = "Invoices"; string sLOAD_MODULE_KEY = "INVOICE_ID"; Guid gQUOTE_ID = CommonTypeConvert.ToGuid(Request["QUOTE_ID"]); Guid gORDER_ID = CommonTypeConvert.ToGuid(Request["ORDER_ID"]); Guid gDuplicateID = CommonTypeConvert.ToGuid(Request["DuplicateID"]); if (!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID) || !CommonTypeConvert.IsEmptyGuid(gQUOTE_ID) || !CommonTypeConvert.IsEmptyGuid(gORDER_ID)) { string innerSql = ApplicationSQL.SQL["Invoices_EditView_323"].ToString(); var oQuery = new InlineQueryDBManager(); oQuery.CommandText = innerSql; if (!CommonTypeConvert.IsEmptyGuid(gQUOTE_ID)) { //Load the data from the QUOTES record. sLOAD_MODULE = "Quotes"; sLOAD_MODULE_KEY = "QUOTE_ID"; innerSql = ApplicationSQL.SQL["Invoices_EditView_333"].ToString(); oQuery.CommandText = innerSql; //Filter by the module we are loading. CRMSecurity.Filter(oQuery, sLOAD_MODULE, "edit"); TypeConvert.AppendParameter(oQuery, gQUOTE_ID, "ID", false); } else if (!CommonTypeConvert.IsEmptyGuid(gORDER_ID)) { // Load the data from the ORDERS record. sLOAD_MODULE = "Orders"; sLOAD_MODULE_KEY = "ORDER_ID"; innerSql = ApplicationSQL.SQL["Invoices_EditView"].ToString(); oQuery.CommandText = innerSql; //Filter by the module we are loading. CRMSecurity.Filter(oQuery, sLOAD_MODULE, "edit"); TypeConvert.AppendParameter(oQuery, gORDER_ID, "ID", false); } else { //Use new CRMSecurity.Filter() function to apply Team and ACL security rules. CRMSecurity.Filter(oQuery, m_sMODULE, "edit"); if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { TypeConvert.AppendParameter(oQuery, gDuplicateID, "ID", false); gID = Guid.Empty; } else { TypeConvert.AppendParameter(oQuery, gID, "ID", false); } } using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; ViewState["BILLING_ACCOUNT_ID"] = CommonTypeConvert.ToGuid(rdr["BILLING_ACCOUNT_ID"]); ViewState["SHIPPING_ACCOUNT_ID"] = CommonTypeConvert.ToGuid(rdr["SHIPPING_ACCOUNT_ID"]); new DynamicControl(this, "QUOTE_ID").ID = CommonTypeConvert.ToGuid(rdr["QUOTE_ID"]); new DynamicControl(this, "ORDER_ID").ID = CommonTypeConvert.ToGuid(rdr["ORDER_ID"]); AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, rdr); AppendEditViewFields(m_sMODULE + ".EditDescription", tblDescription, rdr); //Dynamic buttons need to be recreated in order for events to fire. ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]), rdr); if (!CommonTypeConvert.IsEmptyGuid(gQUOTE_ID)) { new DynamicControl(this, "QUOTE_ID").ID = gQUOTE_ID; new DynamicControl(this, "QUOTE_NAME").Text = CommonTypeConvert.ToString(rdr["NAME"]); ctlEditLineItemsView.LoadLineItems(gQUOTE_ID, Guid.Empty, rdr, sLOAD_MODULE, sLOAD_MODULE_KEY); } else if (!CommonTypeConvert.IsEmptyGuid(gORDER_ID)) { new DynamicControl(this, "ORDER_ID").ID = gORDER_ID; new DynamicControl(this, "ORDER_NAME").Text = CommonTypeConvert.ToString(rdr["NAME"]); ctlEditLineItemsView.LoadLineItems(gORDER_ID, Guid.Empty, rdr, sLOAD_MODULE, sLOAD_MODULE_KEY); } else { ctlEditLineItemsView.LoadLineItems(gID, gDuplicateID, rdr, sLOAD_MODULE, sLOAD_MODULE_KEY); } } else { ctlEditLineItemsView.LoadLineItems(gID, gDuplicateID, null, String.Empty, String.Empty); //If item is not visible, then don't allow save //Dynamic buttons need to be recreated in order for events to fire. ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("ACL.LBL_NO_ACCESS"); } } } else { AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, null); AppendEditViewFields(m_sMODULE + ".EditDescription", tblDescription, null); //Dynamic buttons need to be recreated in order for events to fire. ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); //Prepopulate the Account. Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); if (!CommonTypeConvert.IsEmptyGuid(gPARENT_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 (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts") { UpdateAccount(gPARENT_ID, true, true); } if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts") { UpdateContact(gPARENT_ID, true, true); } else if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Opportunities") { new DynamicControl(this, "OPPORTUNITY_ID").ID = gPARENT_ID; new DynamicControl(this, "OPPORTUNITY_NAME").Text = sPARENT_NAME; } } ctlEditLineItemsView.LoadLineItems(gID, gDuplicateID, new InlineQueryDBManager(), null, String.Empty, String.Empty); } } else { // When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = CommonTypeConvert.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); var ctlBILLING_ACCOUNT_ID = new DynamicControl(this, "BILLING_ACCOUNT_ID"); var ctlSHIPPING_ACCOUNT_ID = new DynamicControl(this, "SHIPPING_ACCOUNT_ID"); if (CommonTypeConvert.ToGuid(ViewState["BILLING_ACCOUNT_ID"]) != ctlBILLING_ACCOUNT_ID.ID) { UpdateAccount(ctlBILLING_ACCOUNT_ID.ID, true, true); ViewState["BILLING_ACCOUNT_ID"] = ctlBILLING_ACCOUNT_ID.ID; ViewState["SHIPPING_ACCOUNT_ID"] = ctlBILLING_ACCOUNT_ID.ID; } if (CommonTypeConvert.ToGuid(ViewState["SHIPPING_ACCOUNT_ID"]) != ctlSHIPPING_ACCOUNT_ID.ID) { UpdateAccount(ctlSHIPPING_ACCOUNT_ID.ID, false, true); ViewState["SHIPPING_ACCOUNT_ID"] = ctlSHIPPING_ACCOUNT_ID.ID; } } }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE)); Visible = (Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!Visible) return; gID = CommonTypeConvert.ToGuid(Request["ID"]); if (!IsPostBack) { Guid gDuplicateID = CommonTypeConvert.ToGuid(Request["DuplicateID"]); if (!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { var oQuery = new InlineQueryDBManager(); string innerSql = ApplicationSQL.SQL["Products_EditView"].ToString(); oQuery.CommandText = innerSql; CRMSecurity.Filter(oQuery, m_sMODULE, "edit"); if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID)) { TypeConvert.AppendParameter(oQuery, gDuplicateID, "ID", false); gID = Guid.Empty; } else { TypeConvert.AppendParameter(oQuery, gID, "ID", false); } using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); AppendEditViewFields(m_sMODULE + ".CostView", tblCost, rdr); AppendEditViewFields(m_sMODULE + ".MftView", tblManufacturer, rdr); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]), rdr); var txtNAME = FindControl("NAME") as TextBox; if (txtNAME != null) txtNAME.ReadOnly = false; } else { ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); ctlDynamicButtons.DisableAll(); ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("ACL.LBL_NO_ACCESS"); } } } else { AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); AppendEditViewFields(m_sMODULE + ".CostView", tblCost, null); AppendEditViewFields(m_sMODULE + ".MftView", tblManufacturer, null); ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null); var txtNAME = FindControl("NAME") as TextBox; if (txtNAME != null) txtNAME.ReadOnly = false; Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]); if (!CommonTypeConvert.IsEmptyGuid(gPARENT_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 (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts") { new DynamicControl(this, "ACCOUNT_ID").ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME; } else if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts") { new DynamicControl(this, "CONTACT_ID").ID = gPARENT_ID; new DynamicControl(this, "CONTACT_NAME").Text = sPARENT_NAME; } } } } else { ctlModuleHeader.Title = CommonTypeConvert.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } }