Tuesday

Manage Stored User Names and Passwords

To manage stored user names and passwords, follow these steps:
  • Log on to the computer as the user whose account you want to change.
  • Click Start, and then click Control Panel.
  • In Control Panel, click User Accounts under Pick a category to open the User Accounts dialog box.
  • Open the Stored User Names and Passwords dialog box; to do so, use the appropriate method:
    • If you log on with a limited account:
      1. Under Related Tasks, click Manage my network passwords.
    • If you log on with an account with administrative privileges:
      1. Under or pick an account to change, click your user account to open the What do you want to change about your account? dialog box.
      2. Under Related Tasks, click the Manage my network passwords.


    A list of stored user names and passwords similar to the following example is displayed:


    more...
  • Friday

    ASP.NET Editable grid

    aspx page:
     
    <div style="overflow:auto;height:150px;border-width:1px;">
    <asp:DataGrid ID="ScheduledPaymentAdjustmentDataGrid" CssClass="TableWithGrayBorders" Runat="server"
    AutoGenerateColumns="False"
    Width="200" BorderStyle="None"
    HeaderStyle-CssClass="TableWithGrayBordersHeader" ShowFooter=true
    HeaderStyle-HorizontalAlign="Center" DataKeyField="sID"
    OnItemCommand="ItemsGrid_Command"
    >

    <Columns>
    <asp:TemplateColumn HeaderText="Profile" ItemStyle-Width="5%" ItemStyle-Wrap=False
    HeaderStyle-HorizontalAlign=Center HeaderStyle-Wrap=False ItemStyle-HorizontalAlign=Center>
    <ItemTemplate>
    <img src="../images/spacer.gif" width=2>
    <asp:DropDownList id="ProfileDropDown" runat="server" Width='150'
    DataSource="<%# GetProfiles() %>"
    DataValueField="id" DataTextField="name"
    SelectedValue='<%# GetProFileId(DataBinder.Eval(Container.DataItem, "sID")) %>'
    />
    <img src="../images/spacer.gif" width=2>
    </ItemTemplate>

    <FooterTemplate>

    <img src="../images/spacer.gif" width=2>
    <asp:DropDownList id="ProfileDropDown" runat="server" Width='150' BackColor="LightGreen"
    DataSource="<%# GetProfiles() %>"
    DataValueField="id" DataTextField="name"
    SelectedValue='<%# GetProFileId(DataBinder.Eval(Container.DataItem, "sID")) %>'
    />
    <img src="../images/spacer.gif" width=2>
    </FooterTemplate>
    </asp:TemplateColumn>


    <asp:TemplateColumn HeaderText="Amount" ItemStyle-Width="5%" ItemStyle-Wrap=False
    HeaderStyle-HorizontalAlign=Center HeaderStyle-Wrap=False ItemStyle-HorizontalAlign=Center>
    <ItemTemplate>
    <img src="../images/spacer.gif" width=2>
    <asp:TextBox ID="AmountTextBox" runat="server" Text='<%# string.Format("{0:0.00}",DataBinder.Eval(Container.DataItem, "dAmount")) %>' Width='70' MaxLength="8" />
    <img src="../images/spacer.gif" width=2>
    </ItemTemplate>

    <FooterTemplate>
    <img src="../images/spacer.gif" width=2>
    <asp:TextBox ID="AmountTextBox" runat="server" BackColor="LightGreen" Text='<%# string.Format("{0:0.00}",DataBinder.Eval(Container.DataItem, "dAmount")) %>' Width='70' MaxLength="8" />
    <img src="../images/spacer.gif" width=2>
    </FooterTemplate>

    </asp:TemplateColumn>


    <asp:TemplateColumn HeaderText="" ItemStyle-Width="1%" ItemStyle-Wrap=False
    HeaderStyle-HorizontalAlign=Center HeaderStyle-Wrap=False ItemStyle-HorizontalAlign=Center>
    <ItemTemplate>

    <asp:ImageButton ID="ImageButton1" Runat="server" CommandName="Delete" ImageUrl ='../images/delete_icon.gif' CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID")%>' />

    </ItemTemplate>

    <FooterTemplate>
    <asp:ImageButton ID="ImageButton2" Runat="server" ImageUrl='../images/bullet_add.png' CommandName="new" />
    </FooterTemplate>

    </asp:TemplateColumn>
    </Columns>

    </asp:DataGrid>



    Code behind:
      
    public void SaveScheduledPaymentAdjustmentDataGridChanges()
    {
    List<InvoiceDetailsRowView> lst = ((List<InvoiceDetailsRowView>)ScheduledPaymentAdjustmentDataGridSource);
    Hashtable H = new Hashtable(lst.Count);

    bool changed = false;
    foreach (InvoiceDetailsRowView i in lst)
    {
    H.Add(i.sID,i);

    }


    foreach (DataGridItem dataGridItem in ScheduledPaymentAdjustmentDataGrid.Items)
    {
    string key =(string) ScheduledPaymentAdjustmentDataGrid.DataKeys[dataGridItem.ItemIndex];
    UpdateInvoiceDetailsRowViewWithCells((InvoiceDetailsRowView)H[key], dataGridItem.Cells);
    }

    ScheduledPaymentAdjustmentDataGridSource = lst;
    }



    public void UpdateInvoiceDetailsRowViewWithCells(InvoiceDetailsRowView i,TableCellCollection Cells )
    {
    TextBox date = (TextBox)Cells[2].FindControl("DateTextBox");
    TextBox Note = (TextBox)Cells[3].FindControl("NoteTextBox");
    TextBox amount = (TextBox)Cells[1].FindControl("AmountTextBox");
    DropDownList dd = (DropDownList)Cells[0].FindControl("ProfileDropDown");

    decimal am;
    assert.IsTrue(decimal.TryParse(amount.Text, out am), iam+" " +amount.Text);
    assert.IsTrue(am > 0, iam + " " + amount.Text);
    i.NoteText = Note.Text;
    i.dAmount = am;
    i.TXNDate = date.Text;
    i.ProfileID = int.Parse(dd.SelectedValue);

    }



    public void ItemsGrid_Command(Object sender, DataGridCommandEventArgs e)
    {

    RunSafe(Process_Command,new object[]{e});
    }

    public void Process_Command(params object[] p)
    {
    DataGridCommandEventArgs e =(DataGridCommandEventArgs) p[0];

    switch (e.CommandName)
    {
    case "Delete":
    SaveScheduledPaymentAdjustmentDataGridChanges();
    DeleteSP((string)ScheduledPaymentAdjustmentDataGrid.DataKeys[e.Item.ItemIndex]);
    break;

    case "new":
    SaveScheduledPaymentAdjustmentDataGridChanges();

    InvoiceDetailsRowView i= new InvoiceDetailsRowView();
    UpdateInvoiceDetailsRowViewWithCells(i, ((System.Web.UI.WebControls.TableRow) (e.Item)).Cells);
    i.status = EnumRecordStatus.added;
    i.sID = Guid.NewGuid().ToString();
    List<InvoiceDetailsRowView> lst = ((List<InvoiceDetailsRowView>)ScheduledPaymentAdjustmentDataGridSource);
    lst.Add(i);
    ScheduledPaymentAdjustmentDataGridSource = lst;
    ScheduledPaymentAdjustmentDataGridBind();
    break;
    }
    GetTotalInBills();
    }


    more...

    Wednesday

    sql:select one row on join

            

    SELECT *
    FROM AccountTransactions AS inv
    INNER JOIN [Accounts basic] a2 ON inv.AccountId = a2.ID
    JOIN ( SELECT *
    FROM ( SELECT *,
    ROW_NUMBER() OVER ( PARTITION BY AccountTransactionId ORDER BY ProcessDate ) AS RowId
    FROM dbo.BillingTransactions
    ) Tmp
    WHERE RowId = 1
    ) b ON inv.TransactionId = b.AccountTransactionId

    more...

    Tuesday

    Select into another table update from another table

    insert into table from select.

    SELECT *
    INTO new_table_name [IN externaldatabase]
    FROM old_tablename


    Update from one table into another

    UPDATE
    Sales_Import
    SET
    AccountNumber = RAN.AccountNumber
    FROM
    Sales_Import SI
    INNER JOIN
    RetrieveAccountNumber RAN
    ON
    SI.LeadID = RAN.LeadID

    more...

    test smtp server with powershell

    Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...