Saturday, December 28, 2013

Show an Server Image in Asp.Net

______________________________________________________
  
1st Work
______________________________________________________
  
DirectoryInfo folder = new DirectoryInfo(@"~/CVImage/");
        string files = Label1.Text.Trim();
        string ext = pic_ex.Text.Trim();
        byte[] imageBytes = File.ReadAllBytes(Server.MapPath("~/CVImage/" + files + ext));
        Session["imagename"] = imageBytes;
        
        Image1.ImageUrl = Server.MapPath("~/UI/get_image.aspx");
        Image1.ImageUrl = "~/UI/get_image.aspx?id=";


_________________________________________________________
2nd work
_________________________________________________________

Create a aspx file name get_image.aspx



protected void Page_Load(object sender, EventArgs e)
    {
         
        try
        {
            byte[] image = (byte[])(Session["imagename"]);
            Response.ContentType = "image/JPEG";
            if (image.Length != 0)
                Response.BinaryWrite(image);

           
        }
        catch { }
    }

Sunday, December 8, 2013

CheckBoxList

<asp:Panel ID="Panel_CBL_Stat_Cv" runat="server" Height="200px" ScrollBars="Both" Visible="false">
           <asp:CheckBoxList ID="CBL_Stat_Cv" runat="server" Visible="false" RepeatColumns = "4" RepeatDirection="Horizontal">
    </asp:CheckBoxList>
  </asp:Panel>


protected void btSave_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < CBL_Stat_Cv.Items.Count; i++)
        {
            string[] fivalue = new string[2];
            fivalue[0] = Label_id.Text.Trim();
            fivalue[1] = "";
            if (CBL_Stat_Cv.Items[i].Selected)
            {
                fivalue[1] += CBL_Stat_Cv.Items[i].Value;
                mydal.Save_recruit_process_details(fivalue);
            }
            
        }
        laMeg.Text = "Save Successfully";
        PopUp();
    }
++++++++++++++++++++++++++++++++++
public void Save_recruit_process_details(string[] fivalue)
            {
                tbl_recruit_process_detail tb = new tbl_recruit_process_detail();
                tb.recruit_process_id = Convert.ToInt16(fivalue[0]);
                tb.status_id = Convert.ToInt32(fivalue[1]);
                db.tbl_recruit_process_details.InsertOnSubmit(tb);
                db.SubmitChanges();

            }

Wednesday, December 4, 2013

Make a Report

রিপোর্ট তৈরি করা অত্যন্ত সহজ একটি কাজ। কিন্তু তা মাথা ঠাণ্ডা রেখে করতে হবে।
কয়েকটি ধাপে এটি করতে হয়।
আমি ধরে নিলাম আমার একটি গ্রিডে আমার কাঙ্ক্ষিত ইউজার আইডিটি আছে। সেই আইডিটি দিয়ে আমি আমার রিপোর্ট বা পিডিএফ বের করে আনব।

প্রথম ধাপ  ঃ


   protected void print_Click(object sender, EventArgs e)
    {
        //এইটা প্রথমে করতে হবে।
        string[] fiv = new string[1];
        fiv[0] = GV_evalute_cv.Rows[0].Cells[0].Text;
        Session["dip_id"] = fiv[0];
        //StringBuilder Script = new StringBuilder();
        String script = "window.open('../Rpt/dip_rip.aspx?que=dip', 'popup', 'location=1, status=1, scrollbars=1')";
         //এখানে Rpt ফোল্ডারের ভিতরে dip_rip.aspx নামে একটি .aspx file তৈরি করতে 
         //হবে। 

        ScriptManager.RegisterClientScriptBlock(this, GetType(), UniqueID, script, true);

    }

২য় ধাপ  ঃ


// window.open('../Rpt/dip_rip.aspx?

তার মানে Rpt নামে একটি folder তৈরি করতে হবে । তার ভিতরে report_cv নামে একটি 

.aspx নিতে হবে। 

যার Content এর ভিতরে Toolbox থেকে একটি CrystalReportViewer নিতে হবে। 



যা কিনা উপরের দৃশ্বীয় মান ছবিটির মন হবে।

এবার ওয়েব সাইট বা প্রোজেক্টের উপর রাইট ক্লিক করে একটি xml ফাইল নেই । আমি এখানে ফাইলটার নাম দিলাম cv.xml

Wednesday, November 27, 2013

নির্দিষ্ঠ আইডি ধরে ওই আইডির নামে ছবি হস্টেটেড ফোল্ডারে সেভ করে রাখা।


এখানে আমি আমার প্রয়োজন অনুসারে কাজটি করেছি ।

প্রথমে একটি লেবেলে ডাটাবেস বা অন্য কোথাও আইডিটি ধরতে হবে। পরে তার সাথে ১ যোগ করে দিতে হবে। যেটা নিজের প্রয়োজন মত। 


if (FileUpload1.HasFile)
{
string[] fileName = FileUpload1.FileName.Split('.');
if ((fileName[fileName.Length - 1] == "jpg") ||
(fileName[fileName.Length - 1] == "gif") ||
(fileName[fileName.Length - 1] == "bmp") ||
(fileName[fileName.Length - 1] == "jpeg") ||
(fileName[fileName.Length - 1] == "png"))
{


string ext = Path.GetExtension(FileUpload1.FileName);
int ID = Convert.ToInt32(last_value.Text)+1;// 32 holo Size
string filename = ID + ext;//DateTime.Now.Ticks.ToString() + ext;
FileUpload1.SaveAs(Server.MapPath("~/CVImage/") + filename);

}

Wednesday, November 20, 2013

ডাটাবেস থেকে ডাটা এনে তা লেবেলে দেখানো ...

প্রথম ধাপ  ঃ

 lbl_country.Text = mydal.lbl_country(type).Rows[0][1].ToString();
 lbl_country_id.Text = mydal.lbl_country(type).Rows[0][0].ToString();



দ্বিতীয় ধাপ  ঃ

 public DataTable lbl_country(int type)
    {
        var result = from p in db.tbl_project_details
                    join c in db.tbl_countries
                    on p.country_id equals c.id
                     where p.project_id == type
                     select new { p.country_id ,c.country_name};
        SqlCommand cmd = db.GetCommand(result) as SqlCommand;
        DataTable dt = new DataTable();
        SqlDataAdapter ad = new SqlDataAdapter(cmd);
        ad.Fill(dt);
        //string la = dt.Rows[0][0].ToString();
        //string  = dt.Rows[0][0].ToString();
        return dt;
    }

Tuesday, November 19, 2013

গ্রিডে ডাটা রেখে তা ডাটাবেসে রাখা

এই পদ্ধতিতে আমরা খুব সহজেই টেক্সট বক্স থেকে ডাটা নিয়ে তা গ্রিডে দেখিয়ে ডাটাবেসে রাখতে পারি।
এই কাজটি ৩টি ধাপে করতে হয়।

প্রথম ধাপঃ
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="frm_project_batch_setup.aspx.cs" Inherits="UI_frm_batch_setup" EnableEventValidation="false" %>

 try 
        {
            DataTable tblCategory;
            if (ViewState["tblCategory"] == null)
            {
                tblCategory = new DataTable();
                tblCategory.Columns.Add("CategoryID");
                //tblCategory.Columns.Add("PId");
                tblCategory.Columns.Add("CategoryName");
                tblCategory.Columns.Add("Vacancy");
                tblCategory.Columns.Add("CountryID");
                tblCategory.Columns.Add("Country");
            }

Sunday, November 17, 2013

পোপ আপ ম্যাসেজ


খুব সহজেই আমরা এএসপি ডট নেটে একটা পোপ আপ ম্যাসেজ তৈরি করতে পারি।
তা নীচের কোডের মাধ্যমে করা সম্ভব। 



using System.Web;

using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Serialization;
protected void btSave_Click(object sender, EventArgs e)
    {
        laMeg.Text = " Hello This is POP_UP";
        PopUp();
}
 public void PopUp()
    {
      ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('" + laMeg.Text + "');", true);
    }

Thursday, October 3, 2013

What is Data Logic Layer (DLL), Business Logic Layer (BLL) And User Interface (UI) ?

It is part of 3-tier or can be used in N-layer architecture. We will start architecture where it is used. Each name itself explain little bit what they exactly mean.
Basically 3-tier included all this, in Tier application we are dividing application into different modules (Layers) to reduce the complexity and more efficient code & easy to manage. 


DLL (Database Logic Layer/
Data Access Layer): As name states, all the concept regarding the Database will go here. Your connectivity, Query, Manipulation, Execution of SQL Query and so on. Will take the same example where you are doing calculation and want to store the values or history in some database table. All the logic will go here. 
 
BLL (Business Logic Layer):
As name states, all the concept what you do with Business will go here. Basically you can say if i am building Calculation application now all the Calculation logic can reside in this layer. You can have interface here and there implementation in this layer for simplicity. 


UI (User Interface):
User Interface is what user see, it will contain all the controls, Java Script which is user facing. You should not write any logic in User Interface area just your UI controls and so forth. 


Are the 3 main layers to develop 3 tier architecture.

The UI 
(User Interface) layer is the one which is our .aspx with code behind file. So what ever we create the .aspx pages, those comes under the UI (User Interface) layer of the architecture.

BLL
(Business Logic Layer)  or the Business Logic Layer is the one, where we can define the business logic, business object or lets say the properties and method which will interact to other layers through out the application.
So in BLL, we can define the public properties as well as the constraints or rules so that before sending the data to the database, we can check it and if it violates the rules, then get the error back to UI 
(User Interface) layer. 

Hence no need to propagate the data to the DAL.
DAL is one the important layer where we define all the methods related to database transactions- Insert, update, Delete, select etc.
So all the stuff which we do at our code behind related to database, is the part of Data-acess layer.