예제 #1
0
        protected void BtnTransfer_Click(object sender, EventArgs e)
        {
            string database  = Session["DatabaseName"].ToString();
            string datatable = "Pro_Resource";
            string bid       = DDL_Bid.SelectedValue;
            string SQLBId    = "Select * from Bid_Library where bid=" + bid;
            string ItemName  = "";

            string    SQLString     = "Pid,ItemName,Unit,Complex,Code,Notes";
            DataTable DataTableBox  = WebModel.LoadSetContentData(database, SQLBId);
            DataTable DataTableBox1 = new DataTable();

            foreach (string DataName in SQLString.Split(','))
            {
                DataTableBox1.Columns.Add(DataName, typeof(string));
            }
            if (DataTableBox != null && DataTableBox.Rows.Count > 0)
            {
                foreach (DataRow row in DataTableBox.Rows)
                {
                    ItemName = row["ItemName"].ToString();

                    bool select = WebModel.ItemName(Session["DatabaseName"].ToString(), datatable, ItemName);
                    if (select == false)
                    {
                        DataRow DataTableDr = DataTableBox1.NewRow();
                        //DataTableDr["PriceID"] = row["PriceID"].ToString();
                        DataTableDr["Pid"]      = Session["ProjectCode"].ToString();
                        DataTableDr["ItemName"] = row["ItemName"].ToString();
                        DataTableDr["Unit"]     = row["Unit"].ToString();
                        DataTableDr["Code"]     = row["Code"].ToString();
                        DataTableDr["Complex"]  = row["Complex"].ToString();
                        DataTableBox1.Rows.Add(DataTableDr);
                        //string InsertSQL = "insert into  [Pro_Resource]  ([PID],[ItemName],[Unit],[Code],[Complex]) VALUES(" + Session["ProjectCode"].ToString() + "," + ItemName + "," + Unit + "," + Code + "," + Complex + ")";
                        //WebModel.SQLAction(database, InsertSQL);
                        //WebModel.SaveAction(database, datatable, GetDataBox());
                        WebModel.SaveAction(database, datatable, DataTableBox1);
                        DataTableBox1.Rows.Clear();
                    }
                }
            }
            ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert(' 已轉入完畢');", true);
        }