Ejemplo n.º 1
0
        private Boolean PrintBilling(System.Web.UI.Control sender)
        {
            bool boRetValue = false;

            int iPrintedBills = 0, iBills = 0;

            foreach (DataListItem item in lstItem.Items)
            {
                HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList");

                if (chkList != null)
                {
                    if (chkList.Checked == true)
                    {
                        iBills++;
                        ImageButton imgPrintBilling = (ImageButton)item.FindControl("imgPrintBilling");
                        if (DateTime.Parse(imgPrintBilling.ToolTip) != DateTime.MinValue && DateTime.Parse(imgPrintBilling.ToolTip) != Constants.C_DATE_MIN_VALUE)
                        {
                            Billing clsBilling       = new Billing();
                            System.Data.DataTable dt = clsBilling.ListBillingDateAsDataTable(CreditType.Individual, long.Parse(chkList.Value), DateTime.Parse(imgPrintBilling.ToolTip));
                            clsBilling.CommitAndDispose();

                            if (dt.Rows.Count > 0)
                            {
                                if (dt.Rows[0]["BillingFile"].ToString().IndexOf(".pdf") > -1)
                                {
                                    if (PdfHelper.PrintPDFs(Constants.ROOT_DIRECTORY_BILLING_WoutG + "/" + dt.Rows[0]["BillingFile"].ToString()))
                                    {
                                        iPrintedBills++;
                                    }
                                }
                                else
                                {
                                    if (PrinterHelper.PrintFile(Constants.ROOT_DIRECTORY_BILLING_WoutG + "/" + dt.Rows[0]["BillingFile"].ToString()))
                                    {
                                        iPrintedBills++;
                                    }
                                }
                            }
                        }
                        boRetValue = true;
                    }
                }
            }

            if (boRetValue)
            {
                string javaScript = "window.alert(" + iPrintedBills.ToString() + "/" + iBills.ToString() + " bills has been successfully printed.');";
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(sender, sender.GetType(), "openwindow", javaScript, true);
            }
            else
            {
                string javaScript = "window.alert('Sorry there was no billing file to print.');";
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(sender, sender.GetType(), "openwindow", javaScript, true);
            }
            return(boRetValue);
        }
Ejemplo n.º 2
0
        public static bool ControlNullChk(System.Web.UI.Page page, string ctr_name)
        {
            System.Web.UI.Control ctr = page.FindControl(ctr_name);
            if (ctr == null)
            {
                return(false);
            }
            string ctrtype = ctr.GetType().ToString();

            ctrtype = ctrtype.Split('.')[ctrtype.Split('.').Length - 1];
            string txt = "";

            switch (ctrtype.Trim())
            {
            case "TextBox":
            {
                txt = (ctr as System.Web.UI.WebControls.TextBox).Text;
                break;
            }

            case "DropDownList":
            {
                txt = (ctr as System.Web.UI.WebControls.DropDownList).SelectedValue;
                break;
            }
            }
            if (txt.Trim() == "")
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes default values from the config file; matches config
        /// values with O.GetType().Name + "_" + [Field/Property Name]
        /// </summary>
        /// <param name="O">Object to initialize values for.</param>
        public static void Initialize(System.Web.UI.Control O)
        {
            if (O.Site != null && O.Site.DesignMode)
            {
                return;
            }
            Type   T  = O.GetType().BaseType;
            string st = T.Name + "_";

            foreach (string s in ConfigurationSettings.AppSettings.AllKeys)
            {
                if (s.IndexOf(st) == 0)
                {
                    try
                    { PropertyInfo P = T.GetProperty(s.Replace(st, ""));
                      if (P != null)
                      {
                          if (P.PropertyType == typeof(string))
                          {
                              P.SetValue(O, Config.Setting(s), null);
                          }
                          else if (P.PropertyType == typeof(bool))
                          {
                              P.SetValue(O, Config.bSetting(s), null);
                          }
                      }
                    }
                    catch (Exception e)
                    {
                        throw new Exception(e.Message + ": " + T.Name + "." + s.Replace(st, ""));
                    }
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 运行客户端JavaScript脚本
 /// </summary>
 /// <param name="ctrl">放置脚本的控件</param>
 /// <param name="code">JavaScript代码</param>
 /// <param name="mode">执行模式</param>
 public static void RunScript(System.Web.UI.Control ctrl, string code, ScriptMode mode)
 {
     if (mode == ScriptMode.BeforeLoad)
     {
         ctrl.Page.ClientScript.RegisterClientScriptBlock(ctrl.GetType(), "jsBlock", code, true);
     }
     else if (mode == ScriptMode.AfterLoad)
     {
         System.Web.UI.HtmlControls.HtmlGenericControl hgc = new System.Web.UI.HtmlControls.HtmlGenericControl();
         hgc.TagName    = "div";
         hgc.InnerHtml  = "<script type=\"text/javascript\">";
         hgc.InnerHtml += code;
         hgc.InnerHtml += "</script>";
         ctrl.Controls.Add(hgc);
     }
     else
     {
         System.Web.UI.ScriptManager.RegisterClientScriptBlock(ctrl, ctrl.GetType(), "jsBlock", code, true);
     }
 }
Ejemplo n.º 5
0
        public static void Show(System.Web.UI.Control _control, string _message)
        {
            if (_message.Contains("違反 PRIMARY KEY 條件約束"))
            {
                _message = "資料重複.";
            }
            if (_message.Contains("違反條件約束"))
            {
                _message = "資料重複.";
            }
            if (_message.Contains("違反 UNIQUE KEY 條件約束"))
            {
                _message = "資料重複.";
            }
            if (_message.Contains("無法以唯一索引"))
            {
                _message = "資料重複.";
            }
            //if (_message.Contains("ORA-02292"))
            //    _message = "資料使用中,無法刪除.";
            //if (_message.Contains("ORA-12899"))
            //    _message = "長度過長.";


            _message = _message.Replace("\r\n", "\\n");
            _message = _message.Replace("\n", "\\n");

            if (System.Web.UI.ScriptManager.GetCurrent(_control.Page) == null)
            {
                _control.Page.ClientScript.RegisterStartupScript(_control.GetType(), "", string.Format("alert(\"{0}\");", _message), true);
            }
            else
            {
                System.Web.UI.ScriptManager.RegisterStartupScript(_control.Page, _control.Page.GetType(), "", string.Format("alert(\"{0}\");", _message), true);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Registers any block types that are not currently registered in Rock.
        /// </summary>
        /// <param name="physWebAppPath">A <see cref="System.String" /> containing the physical path to Rock on the server.</param>
        /// <param name="page">The <see cref="System.Web.UI.Page" />.</param>
        /// <param name="refreshAll">if set to <c>true</c> will refresh name, category, and description for all block types (not just the new ones)</param>
        public static void RegisterBlockTypes( string physWebAppPath, System.Web.UI.Page page, bool refreshAll = false)
        {
            // Dictionary for block types.  Key is path, value is friendly name
            var list = new Dictionary<string, string>();

            // Find all the blocks in the Blocks folder...
            FindAllBlocksInPath( physWebAppPath, list, "Blocks" );

            // Now do the exact same thing for the Plugins folder...
            FindAllBlocksInPath( physWebAppPath, list, "Plugins" );

            // Get a list of the BlockTypes already registered (via the path)
            var rockContext = new RockContext();
            var blockTypeService = new BlockTypeService( rockContext );
            var registered = blockTypeService.Queryable().ToList();

            // for each BlockType
            foreach ( string path in list.Keys)
            {
                if ( refreshAll || !registered.Any( b => b.Path.Equals( path, StringComparison.OrdinalIgnoreCase ) ) )
                {
                    // Attempt to load the control
                    try
                    {
                        System.Web.UI.Control control = page.LoadControl( path );

                        if ( control is Rock.Web.UI.RockBlock )
                        {
                            var blockType = registered.FirstOrDefault( b => b.Path.Equals( path, StringComparison.OrdinalIgnoreCase ) );
                            if ( blockType == null )
                            {
                                // Create new BlockType record and save it
                                blockType = new BlockType();
                                blockType.Path = path;
                                blockTypeService.Add( blockType );
                            }

                            Type controlType = control.GetType();

                            // Update Name, Category, and Description based on block's attribute definitions
                            blockType.Name = Rock.Reflection.GetDisplayName( controlType ) ?? string.Empty;
                            if ( string.IsNullOrWhiteSpace( blockType.Name ) )
                            {
                                // Parse the relative path to get the name
                                var nameParts = list[path].Split( '/' );
                                for ( int i = 0; i < nameParts.Length; i++ )
                                {
                                    if ( i == nameParts.Length - 1 )
                                    {
                                        nameParts[i] = Path.GetFileNameWithoutExtension( nameParts[i] );
                                    }
                                    nameParts[i] = nameParts[i].SplitCase();
                                }
                                blockType.Name = string.Join( " > ", nameParts );
                            }
                            if ( blockType.Name.Length > 100 )
                            {
                                blockType.Name = blockType.Name.Truncate( 100 );
                            }
                            blockType.Category = Rock.Reflection.GetCategory( controlType ) ?? string.Empty;
                            blockType.Description = Rock.Reflection.GetDescription( controlType ) ?? string.Empty;
                        }
                    }
                    catch ( Exception ex )
                    {
                        ExceptionLogService.LogException( new Exception( string.Format("Problem processing block with path '{0}'.", path ), ex ), null );
                    }
                }
            }

            rockContext.SaveChanges();
        
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Registers any block types that are not currently registered in Rock.
        /// </summary>
        /// <param name="physWebAppPath">A <see cref="System.String" /> containing the physical path to Rock on the server.</param>
        /// <param name="page">The <see cref="System.Web.UI.Page" />.</param>
        /// <param name="currentPersonId">A <see cref="System.Int32" /> that contains the Id of the currently logged on <see cref="Rock.Model.Person" />.</param>
        /// <param name="refreshAll">if set to <c>true</c> will refresh name, category, and description for all block types (not just the new ones)</param>
        public void RegisterBlockTypes(string physWebAppPath, System.Web.UI.Page page, int?currentPersonId, bool refreshAll = false)
        {
            // Dictionary for block types.  Key is path, value is friendly name
            var list = new Dictionary <string, string>();

            // Find all the blocks in the Blocks folder...
            FindAllBlocksInPath(physWebAppPath, list, "Blocks");

            // Now do the exact same thing for the Plugins folder...
            FindAllBlocksInPath(physWebAppPath, list, "Plugins");

            // Get a list of the BlockTypes already registered (via the path)
            var registered = Repository.GetAll();

            // for each BlockType
            foreach (string path in list.Keys)
            {
                if (refreshAll || !registered.Any(b => b.Path.Equals(path, StringComparison.OrdinalIgnoreCase)))
                {
                    // Attempt to load the control
                    System.Web.UI.Control control = page.LoadControl(path);
                    if (control is Rock.Web.UI.RockBlock)
                    {
                        var blockType = registered.FirstOrDefault(b => b.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
                        if (blockType == null)
                        {
                            // Create new BlockType record and save it
                            blockType      = new BlockType();
                            blockType.Path = path;
                            blockType.Guid = new Guid();
                            this.Add(blockType, currentPersonId);
                        }

                        Type controlType = control.GetType();

                        // Update Name, Category, and Description based on block's attribute definitions
                        blockType.Name = Rock.Reflection.GetDisplayName(controlType) ?? string.Empty;
                        if (string.IsNullOrWhiteSpace(blockType.Name))
                        {
                            // Parse the relative path to get the name
                            var nameParts = list[path].Split('/');
                            for (int i = 0; i < nameParts.Length; i++)
                            {
                                if (i == nameParts.Length - 1)
                                {
                                    nameParts[i] = Path.GetFileNameWithoutExtension(nameParts[i]);
                                }
                                nameParts[i] = nameParts[i].SplitCase();
                            }
                            blockType.Name = string.Join(" > ", nameParts);
                        }
                        if (blockType.Name.Length > 100)
                        {
                            blockType.Name = blockType.Name.Truncate(100);
                        }
                        blockType.Category    = Rock.Reflection.GetCategory(controlType) ?? string.Empty;
                        blockType.Description = Rock.Reflection.GetDescription(controlType) ?? string.Empty;

                        this.Save(blockType, currentPersonId);
                    }
                }
            }
        }
Ejemplo n.º 8
0
 private void CreateResourceKey(System.Web.UI.Control control, string resourceStringKey)
 {
     ResourceStringKey = String.Concat(control.GetType().Name, "_", resourceStringKey);
 }
Ejemplo n.º 9
0
        static public void SetPageControl(object page, string szName, string szValue)
        {
            System.Web.UI.ControlCollection cc = null;
            ArrayList ret = new ArrayList();

            if (page is System.Web.UI.Page)
            {
                cc = (page as System.Web.UI.Page).Controls;
            }
            else if (page is System.Web.UI.UserControl)
            {
                cc = (page as System.Web.UI.UserControl).Controls;
            }
            else
            {
                return;
            }
            GetPageAllControl(ref ret, cc);
            foreach (object ctrInObj in ret)
            {
                System.Web.UI.Control ctr = (System.Web.UI.Control)ctrInObj;
                Type controlType          = ctr.GetType();
                switch (controlType.ToString())
                {
                case "System.Web.UI.WebControls.TextBox":
                    System.Web.UI.WebControls.TextBox controlTextBoxObj = (System.Web.UI.WebControls.TextBox)ctr;
                    if (controlTextBoxObj.ID == szName)
                    {
                        controlTextBoxObj.Text = szValue;
                    }
                    break;

                case "System.Web.UI.WebControls.Label":
                    System.Web.UI.WebControls.Label controlLabelObj = (System.Web.UI.WebControls.Label)ctr;
                    if (controlLabelObj.ID == szName)
                    {
                        controlLabelObj.Text = szValue;
                    }
                    break;

                case "System.Web.UI.HtmlControls.HtmlInputText":
                    System.Web.UI.HtmlControls.HtmlInputText controlInputObj = (System.Web.UI.HtmlControls.HtmlInputText)ctr;
                    if (controlInputObj.Name == szName || controlInputObj.Name.EndsWith("$" + szName))
                    {
                        controlInputObj.Value = szValue;
                    }
                    break;

                case "System.Web.UI.HtmlControls.HtmlSelect":
                    System.Web.UI.HtmlControls.HtmlSelect controlSelectObj = (System.Web.UI.HtmlControls.HtmlSelect)ctr;
                    if (controlSelectObj.Name == szName || controlSelectObj.Name.EndsWith("$" + szName))
                    {
                        controlSelectObj.Value = szValue;
                    }
                    break;

                case "System.Web.UI.HtmlControls.HtmlInputRadioButton":
                    System.Web.UI.HtmlControls.HtmlInputRadioButton controlRadioButtonObj = (System.Web.UI.HtmlControls.HtmlInputRadioButton)ctr;
                    if (controlRadioButtonObj.Name == szName || controlRadioButtonObj.Name.EndsWith("$" + szName))
                    {
                        if (controlRadioButtonObj.Value == szValue)
                        {
                            controlRadioButtonObj.Checked = true;
                        }
                        else
                        {
                            controlRadioButtonObj.Checked = false;
                        }
                    }
                    break;

                default:
                    //TODO:其它控件
                    break;
                }
            }
        }
Ejemplo n.º 10
0
        public static void GenerateReport(string FileName, ReportDocument rpt, System.Web.UI.Control ClientScriptBlockControl, ExportFormatType pvtExportFormatType)
        {
            try
            {
                ExportOptions exportop          = new ExportOptions();
                DiskFileDestinationOptions dest = new DiskFileDestinationOptions();

                string strFileExtensionName = ".pdf";
                switch (pvtExportFormatType)
                {
                case ExportFormatType.PortableDocFormat: strFileExtensionName = ".pdf"; exportop.ExportFormatType = ExportFormatType.PortableDocFormat; break;

                case ExportFormatType.WordForWindows: strFileExtensionName = ".doc"; exportop.ExportFormatType = ExportFormatType.WordForWindows; break;

                case ExportFormatType.Excel: strFileExtensionName = ".xls"; exportop.ExportFormatType = ExportFormatType.Excel; break;
                }

                string strPath     = System.Web.HttpContext.Current.Server.MapPath(@"\retailplus\temp\");
                string strFileName = FileName + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + strFileExtensionName;

                if (System.IO.File.Exists(strPath + strFileName))
                {
                    System.IO.File.Delete(strPath + strFileName);
                }

                dest.DiskFileName              = strPath + strFileName;
                exportop.DestinationOptions    = dest;
                exportop.ExportDestinationType = ExportDestinationType.DiskFile;
                rpt.Export(exportop); //rpt.Close(); rpt.Dispose();

                // remove the error
                if (pvtExportFormatType == ExportFormatType.WordForWindows || pvtExportFormatType == ExportFormatType.Excel || pvtExportFormatType == ExportFormatType.PortableDocFormat)
                {
                    // the maximum report processing jobs limit configured by your system administrator has been reached.
                    rpt.Close(); rpt.Dispose();
                }

                if (pvtExportFormatType == ExportFormatType.PortableDocFormat)
                {
                    string newWindowUrl = Constants.ROOT_DIRECTORY + "/temp/" + strFileName;
                    string javaScript   = "window.open('" + newWindowUrl + "');";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(ClientScriptBlockControl, ClientScriptBlockControl.GetType(), "openwindow", javaScript, true);
                }
                else
                {
                    string newWindowUrl = Constants.ROOT_DIRECTORY + "/temp/" + strFileName;
                    string javaScript   = "window.open('" + newWindowUrl + "','_self');";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(ClientScriptBlockControl, ClientScriptBlockControl.GetType(), "openwindow", javaScript, true);

                    //System.Diagnostics.Process p = new System.Diagnostics.Process();
                    //p.StartInfo.FileName = System.Web.HttpContext.Current.Server.MapPath(Constants.ROOT_DIRECTORY + "/temp/" + strFileName);
                    //p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                    //p.Start();
                }
            }
            catch (Exception ex) { throw ex; }
        }