コード例 #1
0
ファイル: AdminRole.cs プロジェクト: sanchitnakra/LT
        public List <AdlocationDetails> FetchBranchDetails()
        {
            // AdprojectDetails ProjName = new AdprojectDetails();
            List <AdlocationDetails> listofbranchs = new List <AdlocationDetails>();

            string con = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(con))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("select BranchName from LTBranch", conn);
                //   flag = Convert.ToBoolean(cmd.ExecuteScalar());
                SqlDataReader dr = cmd.ExecuteReader();



                if (dr.FieldCount != 0)
                {
                    while (dr.Read())
                    {
                        AdlocationDetails locName = new AdlocationDetails();
                        locName.BranchName = dr["BranchName"].ToString();
                        listofbranchs.Add(locName);
                    }
                }
                return(listofbranchs);
            }
        }
コード例 #2
0
ファイル: AdProjectByTL.cs プロジェクト: sanchitnakra/LT
        public int InsertBranchToDB(AdlocationDetails AdlocationDetails)
        {
            int row = 0;

            string con = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(con))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("insert into LTBranch values('" + AdlocationDetails.BranchName + "')", conn);
                //   flag = Convert.ToBoolean(cmd.ExecuteScalar());
                row = cmd.ExecuteNonQuery();
                if (row > 0)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }