//儲存資料 protected void SaveAction(object sender, EventArgs e) { string database = Session["DatabaseName"].ToString(); //檢查標題文字 ErrorString += (DropDownList2.SelectedItem) == null ? "標案狀態請選擇!!\\n" : ""; ErrorString += (TxBidName.Text) == string.Empty ? "標案名稱請填入!!\\n" : ""; //確認是否全選 if (ErrorString == "") { //確認選項是否存在或過期 if (Session["UID"] == null) { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert(' 請重新選擇');", true); } else { //確認資料庫是否有資料 if (datacheck(Session["UID"].ToString()) == false) { //因資料庫uid為自動增量,故不使用webmodel //WebModel.SaveAction_BID(database, Add__TableName, GetDataBox()); SQLString = "insert into " + Add__TableName + " (BidName,NickName,Status) values(@BidName,@NickName,@Status)"; //SQLString1 = "UPDATE [Bid_PreData] SET [status] = 1 WHERE [UID] = @UID "; string data = Utility.DBconnection.connect_string(database); using (SqlConnection L_Conn = new SqlConnection(data)) { using (SqlCommand SQLAction = new SqlCommand(SQLString, L_Conn)) { SQLAction.Parameters.Add("@BidName", System.Data.SqlDbType.VarChar).Value = TxBidName.Text; SQLAction.Parameters.Add("@NickName", System.Data.SqlDbType.VarChar).Value = TxNickName.Text; SQLAction.Parameters.AddWithValue("@Status", System.Data.SqlDbType.VarChar).Value = DropDownList2.SelectedItem.Value; SQLAction.CommandType = CommandType.Text; L_Conn.Open(); SQLAction.ExecuteNonQuery(); } } WebModel.EditAction(database, _TableName, Session["uid"].ToString(), GetDataBox_add()); ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('存檔完成');", true); } else { //WebModel.EditAction_bid(database, Add__TableName, Session["bid"].ToString(), GetDataBox()); ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('資料庫已有此案');", true); } } } else { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('" + ErrorString + "');", true); } }
//儲存資料 protected void SaveAction(object sender, EventArgs e) { string database = Session["DatabaseName"].ToString(); //檢查標題文字 //ErrorString += (DDL_CheckNY.SelectedIndex) == 0 ? "是否合格請選擇!!\\n" : ""; //ErrorString += (DDL_GetNY.SelectedIndex) == 0 ? "是否得標請選擇!!\\n" : ""; //ErrorString += (DDL_Check.SelectedIndex) == 0 ? "不合格/未得標原因請選擇!!\\n" : ""; //ErrorString += (DDL_Get.SelectedIndex) == 0 ? "不合格/未得標原因請選擇!!\\n" : ""; ErrorString += (TxFirmName.Text) == "" ? "得標廠商請填入!!\\n" : ""; ErrorString += (TxBidPrice.Text) == "" ? "得標金額請填入!!\\n" : ""; //確認是否全選 if (ErrorString == "") { //確認選項是否存在或過期 if (Session["bid"] == null && Session["uid"] == null) { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert(' 請重新選擇');", true); } else { //確認資料庫是否有資料 //if (datacheck(Session["Bid"].ToString()) == false) //{ bool result = WebModel.EditAction(database, _TableName, Session["uid"].ToString(), GetDataBox()); if (result) { Session["Newbid"] = Session["bid"].ToString(); ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('存檔完成');", true); Response.Write("<script>window.opener.document.getElementById('ContentPlaceHolder1_zzz').click();self.close()</script>"); } else { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('存檔朱敗');", true); } //} //else //{ // WebModel.EditAction(database, _TableName, Session["bid"].ToString(), GetDataBox()); // ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('修改完成');", true); //} } } else { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('" + ErrorString + "');", true); } }
protected void BtnSave_Click(object sender, EventArgs e) { string database = Session["DatabaseName"].ToString(); bool edit = WebModel.EditAction(database, "SubRFQ_Firm", LbUID.Text, GetDataBox()); if (edit) { Response.Write("<script>alert('已存檔!!');</script>"); } else { Response.Write("<script>alert('存檔失敗!!');</script>"); } }
protected void Add_Click(object sender, EventArgs e) { string ErrorString = ""; ErrorString += (DDLLayer.SelectedValue) == "0" ? "請輸入階層!!\\n" : ""; ErrorString += (DDLKind.SelectedValue) == "0" ? "請輸入工項類型!!\\n" : ""; //ErrorString += (DDLDtUpper.SelectedValue) == "0" ? "請輸入上層工項!!\\n" : ""; ErrorString += (TxItemName.Text) == string.Empty ? "請輸入名稱!!\\n" : ""; //ErrorString += (RadioButtonList2.SelectedIndex == -1) ? "請選擇項次編號方式!!\\n" : ""; //確認是否全選 if (ErrorString == "") { string database = Session["DatabaseName"].ToString(); string datatable = "Bid_WBS"; string UpdateItemOrder = ""; if (UID != "") { bool result = WebModel.EditAction(database, "Bid_WBS", UID, GetDataBox1()); if (result) { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert(' 已修改完畢');", true); } else { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert(' 修改失敗');", true); } } else { WebModel.SaveAction(database, datatable, GetDataBox()); } string select = "Select * from BidM0 where bid=" + Session["bid"].ToString(); string BidNumType = WebModel.SItemName(database, select, "BidNumType"); if (BidNumType == "0") { bool result3 = DAL.BidLayerCodeSort.Update_order_num(Session["DatabaseName"].ToString(), Session["bid"].ToString()); UpdateItemOrder = "update Bid_WBS set Bid_WBS.ItemOrder = OrderName from Bid_WBSLayer join BID_WBS on BID_WBS.LayerNum=Bid_WBSLayer.LayerNum join LayerOrder on Bid_WBS.SortNum = LayerOrder.OrderNum and Bid_WBSLayer.LayerKind = LayerOrder.Kind where Bid_WBSLayer.BID=" + Session["Bid"].ToString() + ""; WebModel.SQLAction(database, UpdateItemOrder); Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "addLayerCode();", true);//ajax 新增階層碼 } else if (BidNumType == "1") { bool result3 = DAL.BidLayerCodeSort.Update_order_num(Session["DatabaseName"].ToString(), Session["bid"].ToString()); UpdateItemOrder = "update Bid_WBS set Bid_WBS.ItemOrder = LayerOrder.OrderName from Bid_WBSLayer join BID_WBS on BID_WBS.LayerNum=Bid_WBSLayer.LayerNum join LayerOrder on Bid_WBS.SortNum = LayerOrder.OrderNum and Bid_WBSLayer.LayerKind = LayerOrder.Kind where Bid_WBSLayer.BID=" + Session["Bid"].ToString() + ""; bool result = WebModel.SQLAction(database, UpdateItemOrder); Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "addLayerCode1();", true);//ajax 新增階層碼 } ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert(' 已儲存完畢');", true); //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "addLayerCode();", true);//ajax 新增階層碼 //TxItemName.Text = ""; //DDLLayer.SelectedValue = "1"; //DDLDtUpper.SelectedValue = "1"; //DDLNext.SelectedValue = "1"; //DDLKind.SelectedValue = "0"; //TxNotes.Text = ""; //DDL_BidSelect.DataSourceID = "SqlDataSource2"; //DDL_BidSelect.DataBind(); //DDL_BidSelect_SelectedIndexChanged(this, null); //DDL_BidSelect.SelectedValue = Session["Bid"].ToString(); } else { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('" + ErrorString + "');", true); } }