Archive for Luglio 18th, 2008

My products carousel

maurodx Luglio 18th, 2008


GravarItemLista

CodeKeep C# Feed Luglio 18th, 2008

Description: Grava na tb_item_lista parametros (int intilist_cod, int inttlist_cod)

Link: http://www.codekeep.net/snippets/dbdf224f-4fbe-4608-b515-9bc381271e9c.aspx

       #region *** GravarItemLista ***       
        /// <summary>
        /// Método que grava a ItemLista
        /// Aparecido Donizete 18/07/2008
        /// </summary>
        private void GravarItemLista(int inttilist_cod, int inttlist_cod)
        {
            try
            {
                Item_listaBO objItemListaBO = new Item_listaBO();
                Item_listaVO objItemListaVO = new Item_listaVO();

                objItemListaVO.tilist_cod = inttilist_cod;
                objItemListaVO.tlist_cod = inttlist_cod;
                objItemListaVO.tvist_cod_retaguarda = Convert.ToInt64(Session["tvist_cod_retaguarda"]);
                objItemListaVO.tilistv_LoginIDIncAlt = Session["LoginID"] != null ? Convert.ToInt64(Session["LoginID"]) : -1;
                objItemListaVO.tilistv_DataHoraIncAlt = DateTime.Now;
                objItemListaVO.tilistv_controle_atualizacao = "P";

                objItemListaBO.InsertItemListaVistoria(objItemListaVO);
            }
            catch { }
        }
        #endregion

Popular ddl da tabela tb_item_lista

CodeKeep C# Feed Luglio 18th, 2008

Description: Popula a ddl quando a página for carrega; Ela recebe o nome do ddl, o int com o numero do item na lista, e o numero da vistoria)

Link: http://www.codekeep.net/snippets/4e77a829-7d85-4378-a010-45f1fbed6698.aspx

 private void ddlItemListaDataBind(DropDownList ddlDropList, int intItemLista, long longVistoria)
        {

            try
            {
                Item_listaBO objItemListaBO = new Item_listaBO();
                ddlProcedencia.Items.Clear();
                ddlProcedencia.DataSource = objItemListaBO.GetItem_lista(intItemLista);                
                DataTable dt = new DataTable();                
                ddlProcedencia.DataBind();
                // Permite nulo
                //ddlProcedencia.Items.Insert(0, new ListItem("-", "-1"));
                ucGlobal.SetPositionOfDropDownList(ddlProcedencia, objItemListaBO.GetItem_lista_Vistoria(intItemLista, longVistoria));
            }
            catch (Exception ex)
            {
                this.lblErro.Text = "ERRO na camada View: " + ex.Message;
            }


        }

Registry a button on toolstrip

CodeKeep C# Feed Luglio 18th, 2008

Description: Thêm mô?t button va`o tool strip cu?a shell

Link: http://www.codekeep.net/snippets/98f637b5-f805-472d-9e2b-b232492d38bd.aspx

 ToolStripButton mnuOpenFormMenuItem = new ToolStripButton("Tra cu´u mâ~u ga?ch");
            mnuOpenFormMenuItem.Click += new EventHandler(mnuOpenFormMenuItem_Click);
            WorkItem.UIExtensionSites[Interface.Constants.UIExtensionSiteNames.MainMenu].Add<ToolStripButton>(mnuOpenFormMenuItem);

Add Custom Field Type to SharePoint List

CodeKeep C# Feed Luglio 18th, 2008

Description: This example demonstrated how to programmatically add a custom field type to a SharePoint list.

Link: http://www.codekeep.net/snippets/00c2f48a-8196-472c-bd90-ef4e8f84a80f.aspx

if (!inventoryList.Fields.ContainsField("RegistrationFields"))
{
    SPField f = inventoryList.Fields.CreateNewField("ListColumnPicker", "RegistrationFields");
    ListColumnPickerField lcpf = f as ListColumnPickerField;
    lcpf.ListId = registrationsList.ID.ToString();
    inventoryList.Fields.Add(lcpf as SPField);
}

LinQ simple select with one parameter

CodeKeep C# Feed Luglio 18th, 2008

Description: Select with one parameter and specify specific fields

Link: http://www.codekeep.net/snippets/22efa6c7-342a-4721-9866-0599f28acb75.aspx

            HealthManagementDataContext db = new HealthManagementDataContext();

            var mense = from m in db.Members
                        where m.MemberID == 10000000
                        select new
                        {
                            ID = m.MemberID,
                            Name = m.Name
                        };

File Size as String - Better version

CodeKeep C# Feed Luglio 18th, 2008

Description: This function will return the file size in string.

Link: http://www.codekeep.net/snippets/f3e6aaf3-9c6c-4c67-98a8-a0ab8af6a088.aspx

        public static string GetFileSize(long totalBytes)
        {
            string formattedSize = "0 Bytes";

            if (totalBytes > 0)
            {
                var KB = 1024;
                var MB = KB * KB;
                var GB = MB * KB;
                var formatTemplate = @"{0:##.##}";
                if (totalBytes < KB)
                {
                    formattedSize = string.Format(formatTemplate, totalBytes) + " Bytes";
                }
                else if (totalBytes < MB)
                {
                    formattedSize = string.Format(formatTemplate, totalBytes / KB) + " KB";
                }
                else if (totalBytes < GB)
                {
                    formattedSize = string.Format(formatTemplate, totalBytes / MB) + " MB";
                }
                else
                {
                    formattedSize = string.Format(formatTemplate, totalBytes / GB) + " GB";
                }
            }
            return formattedSize;
        }

Path to EXE

CodeKeep C# Feed Luglio 18th, 2008

Description: Get the path to the executable file in a windows service

Link: http://www.codekeep.net/snippets/ad100dc7-ecb7-4b28-8547-497658b4e79a.aspx

using System.Reflection;

private string _exePath;

        public string ExePath
        {
            get
            {
                _exePath = Assembly.GetEntryAssembly().Location;
                if (_exePath != "")
                    _exePath = _exePath.Substring(0, _exePath.LastIndexOf("\\") + 1);

                return _exePath;
            }
        }