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"]);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetPageTitle(Translation.GetTranslation.Term("ProductTemplates.LBL_LIST_FORM_TITLE"));
            var    oQuery   = new InlineQueryDBManager();
            string innerSql = "  from vwPRODUCT_TEMPLATES_List" + ControlChars.CrLf
                              + " where 1 = 1                   " + ControlChars.CrLf;

            oQuery.CommandText = innerSql;
            if (!IsPostBack)
            {
                new DynamicControl(ctlSearchView, "NAME").Text = CommonTypeConvert.ToString(Request["NAME"]);
            }
            grdMain.OrderByClause("NAME", "asc");
            ctlSearchView.SqlSearchClause(oQuery);
            oQuery.CommandText = "select " + CommonTypeConvert.FormatSelectFields(arrSelectFields)
                                 + oQuery.CommandText
                                 + grdMain.OrderByClause();
            DataTable dt = oQuery.GetTable();

            vwMain             = dt.DefaultView;
            grdMain.DataSource = vwMain;
            if (!IsPostBack)
            {
                grdMain.DataBind();
            }
        }
 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();
             }
         }
     }
 }
Exemplo n.º 6
0
        public static DataTable ReportingModules()
        {
            Cache Cache = HttpRuntime.Cache;
            var   dt    = Cache.Get("vwMODULES_Reporting_" + Security.USER_ID) as DataTable;

            if (dt == null)
            {
                var    oQuery   = new InlineQueryDBManager();
                string innerSql = "select MODULE_NAME             " + ControlChars.CrLf
                                  + "     , DISPLAY_NAME            " + ControlChars.CrLf
                                  + "  from vwMODULES_Reporting     " + ControlChars.CrLf
                                  + " where USER_ID = @USER_ID      " + ControlChars.CrLf
                                  + "    or USER_ID is null         " + ControlChars.CrLf;

                oQuery.CommandText = innerSql;
                oQuery.Add("@USER_ID", SqlDbType.UniqueIdentifier, Security.USER_ID);
                dt = oQuery.GetTable();
                foreach (DataRow row in dt.Rows)
                {
                    row["DISPLAY_NAME"] =
                        Translation.GetTranslation.Term(CommonTypeConvert.ToString(row["DISPLAY_NAME"]));
                }
                Cache.Insert("vwMODULES_Reporting_" + Security.USER_ID, dt, null, DefaultCacheExpiration(),
                             Cache.NoSlidingExpiration);
            }
            return(dt);
        }
Exemplo n.º 7
0
        public string[] ItemNameList(string prefixText, int count)
        {
            var arrItems = new string[0];

            if (Security.USER_ID == Guid.Empty)
            {
                throw (new Exception("Authentication required"));
            }

            var oQuery = new InlineQueryDBManager();

            oQuery.CommandText = ApplicationSQL.SQL["ProductCatalog_AutoComplete_212"].ToString();
            CRMSecurity.Filter(oQuery, "ProductTemplates", "list");
            TypeConvert.AppendParameter(oQuery, prefixText, CommonTypeConvert.SqlFilterMode.StartsWith, "NAME");
            oQuery.CommandText += " order by NAME" + ControlChars.CrLf;

            using (DataTable dt = oQuery.GetTable())
            {
                arrItems = new string[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    arrItems[i] = CommonTypeConvert.ToString(dt.Rows[i]["NAME"]);
                }
            }


            return(arrItems);
        }
        protected void BindGrid()
        {
            string innerSql = "select " + CommonTypeConvert.FormatSelectFields(arrSelectFields)
                              + "  from vwINVOICES_ACTIVITIES" + ControlChars.CrLf;
            var oQuery = new InlineQueryDBManager();

            oQuery.CommandText = innerSql;
            CRMSecurity.Filter(oQuery, m_sMODULE, "list", "ACTIVITY_ASSIGNED_USER_ID");
            TypeConvert.AppendParameter(oQuery, gID, "INVOICE_ID");
            TypeConvert.AppendParameter(oQuery, true, "IS_OPEN", false);
            oQuery.CommandText += grdOpen.OrderByClause("DATE_DUE", "desc");


            using (DataTable dt = oQuery.GetTable())
            {
                foreach (DataRow row in dt.Rows)
                {
                    switch (CommonTypeConvert.ToString(row["ACTIVITY_TYPE"]))
                    {
                    case "Calls":
                        row["STATUS"] = Translation.GetTranslation.Term(".call_direction_dom.", row["DIRECTION"]) +
                                        " " + Translation.GetTranslation.Term(".call_status_dom.", row["STATUS"]);
                        break;
                    }
                }
                vwOpen             = new DataView(dt);
                grdOpen.DataSource = vwOpen;
                grdOpen.DataBind();
            }


            oQuery.CommandText = innerSql;
            CRMSecurity.Filter(oQuery, m_sMODULE, "list", "ACTIVITY_ASSIGNED_USER_ID");
            TypeConvert.AppendParameter(oQuery, gID, "INVOICE_ID");
            TypeConvert.AppendParameter(oQuery, false, "IS_OPEN", false);
            oQuery.CommandText += grdHistory.OrderByClause("DATE_MODIFIED", "desc");


            using (DataTable dt = oQuery.GetTable())
            {
                foreach (DataRow row in dt.Rows)
                {
                    switch (CommonTypeConvert.ToString(row["ACTIVITY_TYPE"]))
                    {
                    case "Calls":
                        row["STATUS"] = Translation.GetTranslation.Term(".call_direction_dom.", row["DIRECTION"]) +
                                        " " + Translation.GetTranslation.Term(".call_status_dom.", row["STATUS"]);
                        break;
                    }
                }
                vwHistory             = new DataView(dt);
                grdHistory.DataSource = vwHistory;
                grdHistory.DataBind();
            }
        }
        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);
            }
        }
Exemplo n.º 10
0
        public static string[] ReportingModulesList()
        {
            DataTable dt  = ReportingModules();
            var       arr = new string[dt.Rows.Count];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                arr[i] = CommonTypeConvert.ToString(dt.Rows[i]["MODULE_NAME"]);
            }
            return(arr);
        }
Exemplo n.º 11
0
        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();
                }
            }
        }
Exemplo n.º 12
0
        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();
                }
            }
        }
Exemplo n.º 13
0
        public static string AssignedUser(Guid gID)
        {
            string sUSER_NAME = String.Empty;

            if (!CommonTypeConvert.IsEmptyGuid(gID))
            {
                var vwAssignedUser = new DataView(AssignedUser());
                vwAssignedUser.RowFilter = "ID = '" + gID + "'";
                if (vwAssignedUser.Count > 0)
                {
                    sUSER_NAME = CommonTypeConvert.ToString(vwAssignedUser[0]["USER_NAME"]);
                }
            }
            return(sUSER_NAME);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        public static string ReportingFilterColumnsListName(string sMODULE_NAME, string sDATA_FIELD)
        {
            Cache Cache      = HttpRuntime.Cache;
            var   sLIST_NAME = Cache.Get("vwSqlColumns_ListName." + sMODULE_NAME + "." + sDATA_FIELD) as string;

            if (sLIST_NAME == null)
            {
                var    oQuery   = new InlineQueryDBManager();
                string innerSql = ApplicationSQL.SQL["_code_CRMCache_529"].ToString();
                oQuery.CommandText = innerSql;
                oQuery.Add("@OBJECTNAME", SqlDbType.VarChar, 100, "vw" + sMODULE_NAME);
                oQuery.Add("@DATA_FIELD", SqlDbType.VarChar, 100, sDATA_FIELD);
                sLIST_NAME = CommonTypeConvert.ToString(oQuery.ExecuteScalar());
                Cache.Insert("vwSqlColumns_ListName." + sMODULE_NAME + "." + sDATA_FIELD, sLIST_NAME, null,
                             DefaultCacheExpiration(), Cache.NoSlidingExpiration);
            }
            return(sLIST_NAME);
        }
Exemplo n.º 16
0
        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"]);
                    }
                }
            }
        }
Exemplo n.º 17
0
        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();
                }
            }
        }
Exemplo n.º 18
0
        public static DataTable ImportModules()
        {
            Cache Cache = HttpRuntime.Cache;
            var   dt    = Cache.Get("vwMODULES_Import_" + Security.USER_ID) as DataTable;

            if (dt == null)
            {
                var    oQuery   = new InlineQueryDBManager();
                string innerSql = ApplicationSQL.SQL["_code_RMCache_392"].ToString();
                oQuery.CommandText = innerSql;
                oQuery.Add("@USER_ID", SqlDbType.UniqueIdentifier, Security.USER_ID);
                dt = oQuery.GetTable();
                foreach (DataRow row in dt.Rows)
                {
                    row["DISPLAY_NAME"] =
                        Translation.GetTranslation.Term(CommonTypeConvert.ToString(row["DISPLAY_NAME"]));
                }
                Cache.Insert("vwMODULES_Import_" + Security.USER_ID, dt, null, DefaultCacheExpiration(),
                             Cache.NoSlidingExpiration);
            }
            return(dt);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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();
                }
            }
        }
Exemplo n.º 22
0
        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);
                }
            }
        }
Exemplo n.º 23
0
        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);
            }
        }
Exemplo n.º 24
0
        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;
                }
            }
        }
Exemplo n.º 25
0
        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();
        }