বৃহস্পতিবার, ১৪ অক্টোবর, ২০২১

sql Row to column

 DECLARE  @pvt TABLE(Present int, [Absent] int);

INSERT INTO @pvt VALUES (10,40);


--Unpivot the table.

SELECT Code, Value

FROM 

   (SELECT Present, Absent   FROM @pvt) p UNPIVOT

   (Value FOR Code IN (Present, [Absent]) )AS unpvt;


রবিবার, ১১ জানুয়ারী, ২০১৫

Dse Live crop from dsebd.org

<div id="frameContainer" style="overflow: hidden; width: 557px; margin-left: 209px; margin-top: -1px;">
<iframe src="http://www.dsebd.org/" scrolling="no" style="width: 721px; height: 114px; margin-top: -70px; margin-left: -181px; padding-left: 0px;"></iframe>
</div>

শনিবার, ৫ এপ্রিল, ২০১৪

Multi row in single column in Sql

query
SELECT  distinct   CONVERT(varchar,EntryDate,103)EntryDate,
    mt.VoucherNo,sum(mt.DAmount)Amt,mt.AccStatement,
    STUFF((SELECT ', ' +(select AccChart.ActName from AccChart where CONVERT(nvarchar(50),AccChart.ActCode)= t2.ActCode) FROM AccGl2014 t2
   WHERE t2.VoucherNo = mt.VoucherNo FOR XML PATH (''))  ,1,2,'')  as AccountName  ,STUFF((SELECT ', ' + t3.Descrp  FROM AccGl2014 t3
     WHERE t3.VoucherNo = mt.VoucherNo FOR XML PATH (''))  ,1,2,'')  as Descrp              
    FROM     dbo.AccGl2014 mt where (mt.AccStatement='JV' or mt.AccStatement='Cash' or mt.AccStatement='Bank' ) and mt.EntryDate
    between '04/01/2014' and '04/05/2014'   group by mt.VoucherNo,mt.EntryDate,mt.AccStatement order by mt.VoucherNo desc


normal code

মঙ্গলবার, ২৫ মার্চ, ২০১৪

Tab control in asp



aspx code:

<asp:Panel ID="PanelMain" HorizontalAlign="Left" runat="server" Width="900px" GroupingText="Accounts Report Controller">

            <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" Width="900px"
                ActiveTabIndex="2">

                <ajaxToolkit:TabPanel ID="TabPanel1" runat="server">
                    <headertemplate>Accounts:</headertemplate>
                    <contenttemplate><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><table align="center" style="width: 850px"><tr><td align="left" class="auto-style3"></td><td align="left"><asp:Label ID="Label2" runat="server" CssClass="labelFont" Font-Bold="true" Font-Size="12px"></asp:Label></td></tr><tr id="TrAcc" visible="false" runat="server"><td id="td1" align="right" class="auto-style3"><asp:Label ID="Label3" runat="server" CssClass="labelFont" Text="Date From:" Font-Bold="true" Font-Size="12px"></asp:Label></td><td id="td2"><asp:TextBox ID="txtDateFrom2" runat="server"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator2"
                    runat="server" ControlToValidate="txtDateFrom2" ErrorMessage="*"
                    ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator><ajaxToolkit:CalendarExtender ID="CalendarExtender2" runat="server"
                    Format="dd/MM/yyyy" TargetControlID="txtDateFrom2"></ajaxToolkit:CalendarExtender><ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender2" runat="server"
                    AcceptNegative="None" DisplayMoney="Left" ErrorTooltipEnabled="True"
                    Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true"
                    OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError"
                    TargetControlID="txtDateFrom2"></ajaxToolkit:MaskedEditExtender></td></tr><tr id="Tr2" visible="false" runat="server"><td align="right" class="auto-style3">Date To: </td><td><asp:TextBox ID="txtDateToAcc" runat="server"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator4"
                    runat="server" ControlToValidate="txtDateToAcc" ErrorMessage="*"
                    ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator><ajaxToolkit:CalendarExtender ID="CalendarExtender3" runat="server"
                    Format="dd/MM/yyyy" TargetControlID="txtDateToAcc"></ajaxToolkit:CalendarExtender><ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender3" runat="server"
                    AcceptNegative="None" DisplayMoney="Left" ErrorTooltipEnabled="True"
                    Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true"
                    OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError"
                    TargetControlID="txtDateToAcc" /></td></tr><tr class="rowCss"><td colspan="2" align="left">
                        <asp:RadioButtonList ID="RadioButtonListAcc" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rdbListGen_SelectedIndexChanged"
                                                Width="100%"><asp:ListItem Text="Account List" Value="4"></asp:ListItem><asp:ListItem Text="Account List Summary" Value="5">

                     </asp:ListItem></asp:RadioButtonList></td></tr><tr><td align="left" class="auto-style3"></td>
                         <td align="center">
                         <asp:Button ID="BtnAcc" runat="server" Text="View" CssClass="button" OnClick="BtnAcc_Click" /></td></tr></table>

                        </ContentTemplate>
                        <Triggers><asp:PostBackTrigger ControlID="BtnAcc" />

                        </Triggers>
                                     </asp:UpdatePanel>
                    </contenttemplate>
                </ajaxToolkit:TabPanel>

                <ajaxToolkit:TabPanel ID="TabPanelGeneral" runat="server">
                    <headertemplate>Balance Sheet:</headertemplate>
                    <contenttemplate><asp:UpdatePanel ID="Up1" runat="server"><ContentTemplate><table align="center" style="width: 850px"><tr><td align="left" class="auto-style3"></td><td align="left"><asp:Label ID="lblError" runat="server" CssClass="labelFont" Font-Bold="true" Font-Size="12px"></asp:Label></td></tr><tr id="TrDf" visible="false" runat="server"><td id="tdradio2" align="right" class="auto-style3"><asp:Label ID="Label1" runat="server" CssClass="labelFont" Text="Date From:" Font-Bold="true" Font-Size="12px"></asp:Label></td><td id="tdradio3"><asp:TextBox ID="txtDateFrom" runat="server"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator3"
                    runat="server" ControlToValidate="txtDateFrom" ErrorMessage="*"
                    ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator><ajaxToolkit:CalendarExtender ID="CalendarExtenderCd" runat="server"
                    Format="dd/MM/yyyy" TargetControlID="txtDateFrom"></ajaxToolkit:CalendarExtender><ajaxToolkit:MaskedEditExtender ID="MaskedEditExtenderCD" runat="server"
                    AcceptNegative="None" DisplayMoney="Left" ErrorTooltipEnabled="True"
                    Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true"
                    OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError"
                    TargetControlID="txtDateFrom" /></td></tr><tr id="TrDt" visible="false" runat="server"><td align="right" class="auto-style3">Date To: </td><td><asp:TextBox ID="txtDateTo" runat="server"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator1"
                    runat="server" ControlToValidate="txtDateTo" ErrorMessage="*"
                    ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator><ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server"
                    Format="dd/MM/yyyy" TargetControlID="txtDateTo"></ajaxToolkit:CalendarExtender><ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
                    AcceptNegative="None" DisplayMoney="Left" ErrorTooltipEnabled="True"
                    Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true"
                    OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError"
                    TargetControlID="txtDateTo" /></td></tr><tr><td id="tdradio" colspan="2" align="left"><asp:RadioButtonList ID="rdbListGen" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rdbListGen_SelectedIndexChanged"
                                                Width="100%"><asp:ListItem Text="Balance Sheet" Value="1"></asp:ListItem><asp:ListItem Text="WS Stock Report(Item Wise)" Value="2"></asp:ListItem></asp:RadioButtonList></td></tr><tr><td align="left" class="auto-style3"></td><td align="center"><asp:Button ID="btnGeneral" runat="server" Text="View" CssClass="button" OnClick="btnGeneral_Click" /></td></tr></table></ContentTemplate><Triggers><asp:PostBackTrigger ControlID="btnGeneral" /></Triggers></asp:UpdatePanel></contenttemplate>
                </ajaxToolkit:TabPanel>


                <ajaxToolkit:TabPanel ID="TabPanelPl" runat="server">
                    <headertemplate>Profit &amp; Loss:</headertemplate>
                    <contenttemplate>
                        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                            <ContentTemplate><table align="center" style="width: 850px">
                        <tr id="TrplDt" visible="true" runat="server">
                            <td align="left" class="auto-style3"></td>
                            <td align="left">
                                <asp:Label ID="Label4" runat="server" CssClass="labelFont" Font-Bold="true" Font-Size="12px"></asp:Label>
                            </td></tr><tr id="Tr1" visible="true" runat="server">
                                          <td id="td3" align="right" class="auto-style3">
                                              <asp:Label ID="Label5" runat="server" CssClass="labelFont" Text="Date From:" Font-Bold="true" Font-Size="12px"></asp:Label>
                                          </td><td id="td4"><asp:TextBox ID="dfTextBoxPl" runat="server"></asp:TextBox>
                                              <asp:RegularExpressionValidator ID="RegularExpressionValidator5"
                    runat="server" ControlToValidate="dfTextBoxPl" ErrorMessage="*"
                    ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator><ajaxToolkit:CalendarExtender ID="CalendarExtender4" runat="server"
                    Format="dd/MM/yyyy" TargetControlID="dfTextBoxPl"></ajaxToolkit:CalendarExtender><%--<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender4" runat="server"
                    AcceptNegative="None" DisplayMoney="Left" ErrorTooltipEnabled="True"
                    Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true"
                    OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError"
                    TargetControlID="dfTextBoxPl"></ajaxToolkit:MaskedEditExtender>--%></td>
                                      </tr>
                   
                    <tr id="Tr4" visible="true" runat="server"><td align="right" class="auto-style3">Date To: </td>
                        <td>
                            <asp:TextBox ID="dtTextBoxPL" runat="server">
                               
                            </asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator7"
                    runat="server" ControlToValidate="dtTextBoxPL" ErrorMessage="*"
                    ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator>
                        <ajaxToolkit:CalendarExtender ID="CalendarExtender6" runat="server"  Format="dd/MM/yyyy" TargetControlID="dtTextBoxPL">
                       </ajaxToolkit:CalendarExtender><%--<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender6" runat="server"
                    AcceptNegative="None" DisplayMoney="Left" ErrorTooltipEnabled="True"
                    Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true"
                    OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError"
                    TargetControlID="dtTextBoxPL" />--%>
                                                                                                                   </td></tr>
                        <tr class="rowCss"><td colspan="2" align="left">
                     
                            <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rdbListGen_SelectedIndexChanged" Width="100%">
                                <asp:ListItem Text="P&L (Date Range)" Value="7"></asp:ListItem>
                                <asp:ListItem Text="P&L (Date Range) Year on Year " Value="8"></asp:ListItem>
                                <asp:ListItem Text=" P&L" Value="9"></asp:ListItem>

                            </asp:RadioButtonList>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   </td></tr><tr><td align="left" class="auto-style3"></td><td align="center"><asp:Button ID="ButtonPl" runat="server" Text="View" CssClass="button" OnClick="BtnPl_Click" /></td></tr></table>
                                                                                       </ContentTemplate><Triggers><asp:PostBackTrigger ControlID="ButtonPl" /></Triggers>
                                     </asp:UpdatePanel>
                    </contenttemplate>
                </ajaxToolkit:TabPanel>

                <ajaxToolkit:TabPanel ID="TabPanelCashFlow" runat="server">
                    <headertemplate>Cash Flow:</headertemplate>
                    <contenttemplate><asp:UpdatePanel runat="server" ID="UpdatePanel2"><ContentTemplate></ContentTemplate></asp:UpdatePanel></contenttemplate>
                </ajaxToolkit:TabPanel>

            </ajaxToolkit:TabContainer>
        </asp:Panel>

শনিবার, ১ ফেব্রুয়ারী, ২০১৪

Gridview Code in asp.net with ConboBox,TextBov And Button

Code in aspx:

 <asp:GridView ID="GridView1" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" runat="server" Width="100%" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowDataBound="GridView1_RowDataBound1" SelectedIndex="0" CellPadding="0" ForeColor="Black" GridLines="None">
                                    <HeaderStyle CssClass="HeaderCSS" BackColor="#CCCCCC" Font-Bold="True" ForeColor="Black" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                                    <RowStyle ForeColor="#333333" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                                    <%-- BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center"--%>
                                    <Columns>

                                        <asp:TemplateField HeaderStyle-CssClass="gridViewHeader" HeaderText="Account Name-Code" ItemStyle-CssClass="ItemStyle">
                                            <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                                            <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                                            <ItemTemplate>
                                                <asp:DropDownList ID="gvDdlAccountName" CssClass="ddlCSS" runat="server" DataField="ActName" Width="197px" AutoPostBack="False">
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                            <%-- <HeaderStyle CssClass="gridViewHeader" />--%>
                                        </asp:TemplateField>

                                        <asp:TemplateField HeaderStyle-CssClass="gridViewHeader" HeaderText="  Debit" ItemStyle-CssClass="ItemStyle">
                                            <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                                            <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                                            <ItemTemplate>
                                                <asp:TextBox ID="debitTxt" DataField="Debit" runat="server" CssClass="txtCssDr" Width="180px"></asp:TextBox>
                                            </ItemTemplate>
                                            <HeaderStyle CssClass="gridViewHeader" />
                                        </asp:TemplateField>

                                        <asp:TemplateField HeaderStyle-CssClass="gridViewHeader" HeaderText="  Credit" ItemStyle-CssClass="ItemStyle">
                                            <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                                            <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                                            <ItemTemplate>
                                                <asp:TextBox ID="creditTxt" runat="server" DataField="Credit" Width="180px" CssClass="txtCssCr"></asp:TextBox>
                                            </ItemTemplate>
                                            <HeaderStyle CssClass="gridViewHeader" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderStyle-CssClass="gridViewHeader" HeaderText="Action" ItemStyle-CssClass="cssAction">
                                            <ItemTemplate>
                                                <asp:Button ID="btnAdd" runat="server" Text="Add" Width="85px" OnClick="btnAdd_Click" UseSubmitBehavior="False" />
                                            </ItemTemplate>
                                            <HeaderStyle CssClass="gridViewHeader" />
                                        </asp:TemplateField>
                                    </Columns>
                                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                                </asp:GridView>

C# Code:

  protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {

                    DropDownList gvDdlAccountName = (DropDownList)e.Row.FindControl("gvDdlAccountName");
                    TextBox debitTextBox = (TextBox)e.Row.FindControl("debitTxt");
                    TextBox creditTxtBox = (TextBox)e.Row.FindControl("creditTxt");
                    Button btn = (Button)e.Row.FindControl("btnAdd");
                    string ab = "";
                    if (gvDdlAccountName != null )
                    {
                        gvDdlAccountName.DataSource =(DataTable) Session["AllAccount"];

                         ab =((DataRowView) e.Row.DataItem)[2].ToString();
                        if(ab!="")
                        gvDdlAccountName.SelectedValue = ab;
                        gvDdlAccountName.DataTextField = "ActName";
                        gvDdlAccountName.DataValueField = "ActCode";
                        gvDdlAccountName.DataBind();
                    }
                    if (debitTextBox != null)
                    {
                        debitTextBox.Text = String.Format("{0:0.00}", ((DataRowView)e.Row.DataItem)[4]);
                        if(debitTextBox.Text!="")
                        totalDebit += Convert.ToDouble(debitTextBox.Text);
                    }
                    if (creditTxtBox != null)
                    {
                        creditTxtBox.Text = String.Format("{0:0.00}", ((DataRowView)e.Row.DataItem)[5]);
                        if (creditTxtBox.Text != "")
                        totalCredit += Convert.ToDouble(creditTxtBox.Text);
                    }
                    if (ab != "")
                    {
                        btn.Text = "Delete";
                        btn.CommandArgument = ((DataRowView)e.Row.DataItem)[0].ToString();
                    }
                }
            }
            catch (Exception exp)
            {
                Show(exp.Message);
            }
        }


   protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string comm = ((Button) sender).CommandArgument;
                if (comm == "")
                {
                    String user = HttpContext.Current.User.Identity.Name;
                    DropDownList gvDdlAccountName =
                        (DropDownList) GridView1.Rows[GridView1.SelectedIndex].FindControl("gvDdlAccountName");
                    TextBox debitTextBox = (TextBox) GridView1.Rows[GridView1.SelectedIndex].FindControl("debitTxt");
                    TextBox creditTxtBox = (TextBox) GridView1.Rows[GridView1.SelectedIndex].FindControl("creditTxt");

                    if (txtDate.Text.Trim() == "")
                    {
                        Show("Please insert date");
                        return;
                    }

                    double debit = 0;
                    double credit = 0;
                    if (debitTextBox.Text.Trim() != "")
                        debit = Convert.ToDouble(debitTextBox.Text.Trim());
                    if (creditTxtBox.Text.Trim() != "")
                        credit = Convert.ToDouble(creditTxtBox.Text.Trim());
                    if (debit == 0 || credit == 0)
                    {
                        AccTransectionInfo ati = new AccTransectionInfo
                        {
                            ActCode = gvDdlAccountName.SelectedValue.Trim(),
                            ActName = gvDdlAccountName.SelectedItem.Text.Trim().Split('-')[0],
                            Debit = debit,
                            Credit = credit,
                            EntryBy = user,
                            Comments = txtComment.Text.Trim()
                        };
                        u.CommonSqlExecutionBool(
                            "INSERT INTO [dbo].[AccTransTemp]([EntryBy] ,[ActCode],[ActName],[Debit],[Credit],[Comments])" +
                            " VALUES ( '" + ati.EntryBy + "','" + ati.ActCode + "','" + ati.ActName + "','" + ati.Debit +
                            "' ,'" +
                            ati.Credit + "','" + ati.Comments + "') ");


                        FillGrid();
                        ClearPage();

                    }
                    else
                    {
                        Show("Debit Or Credit Must be 0.");
                    }
                }
                else
                {
                    
                    u.CommonSqlExecutionBool("DELETE FROM AccTransTemp WHERE Sl='" + comm + "'");
                    FillGrid();
                }
            }
            catch (Exception ex)
            {

                Show(ex.Message.ToString());
            }

        }

Gridview Code in asp.net with update And link url

  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                        Width="100%" AllowPaging="True" DataKeyNames="VoucherNo"
                        OnPageIndexChanging="GridView1_PageIndexChanging"
                        OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating"
                        OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDeleting="GridView1_RowDeleting" OnRowDataBound="GridView1_RowDataBound" PageSize="7" OnRowCommand="GridView1_RowCommand">
                        <Columns>
                            <asp:CommandField ShowEditButton="True" HeaderText="Edit">
                                <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center" />
                                <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />

                            </asp:CommandField>

                            <asp:ButtonField HeaderText="View" Text="View" CommandName="VoucherNo" SortExpression="VoucherNo">
                                <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center" Width="40px" />
                                <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                            </asp:ButtonField>

                            <asp:BoundField DataField="EntryDate" HeaderText="Date" ReadOnly="True" DataFormatString="{0:d}">
                                <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center" />
                                <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" Width="120px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="AccountName" HeaderText="Account Name" DataFormatString="{0:0.00}" ReadOnly="True">
                                <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CssClass="HeaderStylCenter" />
                                <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Left" />
                            </asp:BoundField>
                            <%--  <asp:BoundField DataField="ToAcc" HeaderText="To Account" ReadOnly="True">
                                                    <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CssClass="HeaderStylCenter"  />
                                                    <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Right" />
                                                </asp:BoundField>--%>
                            <asp:BoundField DataField="DAmount" HeaderText="Debit" ReadOnly="True" DataFormatString="{0:0.00}">
                                <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CssClass="HeaderStylRight" Width="100px" />
                                <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CssClass="HeaderStylRight" />
                            </asp:BoundField>
                            <asp:BoundField DataField="CAmount" HeaderText="Credit" ReadOnly="True" DataFormatString="{0:0.00}">
                                <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CssClass="HeaderStylRight" Width="100px" />
                                <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CssClass="HeaderStylRight" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Balance" HeaderText="Balance" ReadOnly="True" DataFormatString="{0:0.00}">
                                <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CssClass="HeaderStylRight" Width="100px" />
                                <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CssClass="HeaderStylRight" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Descrp" HeaderText="Comments">
                                <HeaderStyle BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center" />
                                <ItemStyle BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" />
                            </asp:BoundField>

                        </Columns>
                    </asp:GridView>

C# code:

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "VoucherNo")
            {
                string nov = ((GridView) e.CommandSource).DataKeys[1].Value.ToString();
                Session["nov"] = nov;
                Response.Write("<script> window.open('ViewJournalDetailsUI.aspx','_blank')</script>");
            }

        }

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow rowIndex = GridView1.Rows[e.RowIndex];
                string vno = GridView1.DataKeys[e.RowIndex].Values["VoucherNo"].ToString();
                string comment = ((TextBox)(rowIndex.Cells[7].Controls[0])).Text;
                comment = comment.Replace("'", "''");
                if (UpdateData(vno, comment))
                {
                    Show("Updated");
                    GridView1.EditIndex = -1;
                }
                else
                {
                    Show("Error Updating");
                }
                FillGrid();

            }
            catch (Exception ex)
            {
                Show(ex.Message.ToString());
            }
        }




বুধবার, ৫ সেপ্টেম্বর, ২০১২

python parallel port on Windows


python parallel port on Windows

Tried different ways of controlling parallel port with Python on Windows. The easiest way is with Inpout32.dll.

Just download the dll, put it in system32 folder. Then from python:
from ctypes import windll
p = windll.inpout32
p.Inp32(0x378) #default 255(all high) on my pc
p.Out32(0x378, 0) #put all low on port 2-9


The address 0x378 might be different on your machine, open System->Hardware->Device Manager->Ports->ECP Printer Port->Properties->Resources, use the first number as your address.