本文整理汇总了C#中SQLDB.ExecuteStatement方法的典型用法代码示例。如果您正苦于以下问题:C# SQLDB.ExecuteStatement方法的具体用法?C# SQLDB.ExecuteStatement怎么用?C# SQLDB.ExecuteStatement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLDB
的用法示例。
在下文中一共展示了SQLDB.ExecuteStatement方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DelMaterial
public bool DelMaterial(string materialid)
{
bool suc = false;
SQLDB _operator = new SQLDB();
string deletestring = "DELETE ICS_Material where NO= '" + materialid + "'";
suc = _operator.ExecuteStatement(deletestring);
return suc;
}
示例2: gv_RowCommand
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cmd_delete")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gv.Rows[index];
string filename = row.Cells[0].Text;
string delete = " delete StudyFileUpload where FileName = '" + filename + "'";
SQLDB _operator = new SQLDB();
if (_operator.ExecuteStatement(delete))
{
ShowMsg(UpdatePanel1, "刪除成功");
SearchData();
}
try
{
string strDestPath = Server.MapPath("../Temp/");
FileInfo TheFile = new FileInfo(@strDestPath+filename);
if (TheFile.Exists)
{
File.Delete(@strDestPath + filename);
}
else
{
throw new FileNotFoundException();
}
}
catch (FileNotFoundException ex)
{
ShowMsg(UpdatePanel1, ex.Message);
}
catch (Exception ex)
{
ShowMsg(UpdatePanel1, ex.Message);
}
}
}
示例3: lnkbtn_Add_Click
//private void ExportTOExcel()
//{
// ExcelReport report = null;
// try
// {
// report = new ExcelReport("MIS/EquipmentData");
// DataSet ds = (DataSet)Session["DS_MIS"];
// for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
// {
// report.FillData(j + 3, 1, ds.Tables[0].Rows[j]["DeviceID"].ToString(), 1);
// report.FillData(j + 3, 2, ds.Tables[0].Rows[j]["DeviceModelName"].ToString(), 1);
// report.FillData(j + 3, 3, ds.Tables[0].Rows[j]["RegionName"].ToString(), 1);
// report.FillData(j + 3, 4, ds.Tables[0].Rows[j]["SectorName"].ToString(), 1);
// report.FillData(j + 3, 5, ds.Tables[0].Rows[j]["TCModel"].ToString(), 1);
// report.FillData(j + 3, 6, ds.Tables[0].Rows[j]["ContractName"].ToString(), 1);
// report.FillData(j + 3, 7, ds.Tables[0].Rows[j]["DeviceStatus"].ToString(), 1);
// report.FillData(j + 3, 8, ds.Tables[0].Rows[j]["DeviceNote"].ToString(), 1);
// report.FillData(j + 3, 9, ds.Tables[0].Rows[j]["Longitude"].ToString(), 1);
// report.FillData(j + 3, 10, ds.Tables[0].Rows[j]["Latitude"].ToString(), 1);
// //report.FillData(j + 1, 2, ds.Tables[0].Rows[j]["DevicePhoto"].ToString(), 1);
// }
// ScriptManager.RegisterStartupScript(this, this.GetType(), "newprintwindow2", "open_new_window(\"../Temp/" + report.Report() + "\");", true);
// }
// catch (Exception e)
// {
// if (report != null)
// {
// ScriptManager.RegisterStartupScript(this, this.GetType(), "newprintwindow2", "open_new_window(\"../Temp/" + report.Report() + "\");", true);
// }
// }
// finally
// {
// try
// {
// report.Close();
// }
// catch (Exception ex)
// {
// }
// }
//}
/// <summary>
/// 重新計算檢修周期:以設備合約起始日期開始累加檢修週期直到合約截止
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lnkbtn_Add_Click(object sender, EventArgs e)
{
SQLDB db = new SQLDB();
//先將舊有檢修日期刪除
string deleteCheckDate = "Delete from CD_DeviceCheckDate where 1=1";
db.ExecuteStatement(deleteCheckDate);
string queryDevice = "SELECT [Device_ID],[ContractStartDate],[ContractEndDate],[Cycle] FROM [View_DeviceConfig] where [ContractStartDate] is not null and [ContractEndDate] is not null";
DataSet ds = db.SelectQuery(queryDevice);
DataSet ds_checkdate = db.Select("1 = 0", "", "CD_DeviceCheckDate");
for (int i = 0; i < ds.Tables[0].Rows.Count ; i++)
{
string device = ds.Tables[0].Rows[i]["Device_ID"].ToString();
DateTime start = Convert.ToDateTime(ds.Tables[0].Rows[i]["ContractStartDate"].ToString());
DateTime end = Convert.ToDateTime(ds.Tables[0].Rows[i]["ContractEndDate"].ToString());
TimeSpan cycle = TimeSpan.FromDays( Convert.ToDouble( ds.Tables[0].Rows[i]["cycle"].ToString()));
while (start < end)
{
start += cycle;
if (start < end)
{
DataRow dr = ds_checkdate.Tables[0].NewRow();
dr["Device_ID"] = ds.Tables[0].Rows[i]["Device_ID"].ToString();
dr["CheckDate"] = start.ToString("yyyy/MM/dd HH:mm:ss");
ds_checkdate.Tables[0].Rows.Add(dr);
}
}
}
//開始將檢修日期塞到資料庫
DataSet DSChange = ds_checkdate.GetChanges();
if (db.Insert(DSChange))
{
ShowMsg(UpdatePanel1, "資料計算成功");
}
}
示例4: DeleteStockIn
//刪除入庫紀錄單、入庫單內容、計畫分攤成本
private void DeleteStockIn(string stockinid)
{
string userid = (string)Session["UserID"];
SQLDB db = new SQLDB();
#region 更新庫存量資料表相關欄位
//DataSet ds_StockInItem = db.Select("StockInID = '" + stockinid + "'", "", "ICS_StockIn_Item");
//if (ds_StockInItem.Tables[0].Rows.Count> 0)
//{
// //更新庫存量
// //庫存數量 = 目前庫存數量+(入庫數 X 轉換係數)
// //查詢庫存資料
// DataSet ds_inventory = db.Select("", "", "ICS_Inventory");
// //查詢物料轉換係數
// DataSet ds_material = db.Select("", "", "ICS_Material");
// for (int i = 0; i < ds_StockInItem.Tables[0].Rows.Count; i++)
// {
// string materialid = ds_StockInItem.Tables[0].Rows[i]["MaterialID"].ToString();
// string materialName = ds_StockInItem.Tables[0].Rows[i]["MaterialName"].ToString();
// int stockInQuantity = Convert.ToInt32(ds_StockInItem.Tables[0].Rows[i]["StockIn_Quantity"].ToString());
// int materialValue = Convert.ToInt32(ds_StockInItem.Tables[0].Rows[i]["Material_Single_Value"].ToString());
// int stockinCost = Convert.ToInt32(ds_StockInItem.Tables[0].Rows[i]["StockIn_Cost"].ToString());
// DataRow[] dr_invertory = ds_inventory.Tables[0].Select("MaterialID = '" + materialid + "'");
// DataRow[] dr_material = ds_material.Tables[0].Select("NO = '" + materialid + "'");
// double ConversionFactor = Convert.ToDouble(dr_material[0]["ConversionFactor"].ToString());//轉換係數
// //若庫存有資料
// if (dr_invertory.Length > 0)
// {
// double invetory_stockinquantity = Convert.ToDouble(dr_invertory[0]["StockInQuantity"].ToString());//庫存購入數量
// double invetory_q = Convert.ToDouble(dr_invertory[0]["Quantity"].ToString());//庫存量
// double inventoryCost = Convert.ToDouble(dr_invertory[0]["InventoryCost"].ToString());//庫存成本
// //更新庫存購入數量:庫存購入數量-(刪除)入庫量
// double INStockInQuantity = invetory_stockinquantity - stockInQuantity;
// if (INStockInQuantity < 0)
// dr_invertory[0]["StockInQuantity"] = 0;
// else
// dr_invertory[0]["StockInQuantity"] = INStockInQuantity;
// //更新庫存數量:庫存數量 = 目前庫存數量-((刪除)入庫數 X 轉換係數)
// double quantity =invetory_q - (stockInQuantity * ConversionFactor);
// if (quantity < 0)
// dr_invertory[0]["Quantity"] = 0;
// else
// dr_invertory[0]["Quantity"] = invetory_q - (stockInQuantity * ConversionFactor);
// //更新料價: (庫存成本-(刪除)入庫成本)/(庫存數量-(刪除)入庫數量)
// if ((inventoryCost - stockinCost) <= 0 || (stockInQuantity - invetory_stockinquantity) <= 0 || (invetory_stockinquantity - stockInQuantity) <= 0)
// {
// dr_invertory[0]["MaterialCost"] = 0;
// dr_invertory[0]["InventoryCost"] = 0;
// }
// else
// { //更新料價: (庫存成本-(刪除)入庫成本)/(庫存數量-(刪除)入庫數量)
// dr_invertory[0]["MaterialCost"] = (inventoryCost - stockinCost) / (invetory_stockinquantity -stockInQuantity);
// //更新庫存成本:料價 X (刪除)庫存購入數量
// dr_invertory[0]["InventoryCost"] = (inventoryCost - stockinCost) / (invetory_stockinquantity - stockInQuantity) * (invetory_stockinquantity - stockInQuantity);
// }
// dr_invertory[0]["UpdateTime"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
// }
// }
// DataSet ds_invetoryEdit = ds_inventory.GetChanges();
// if (db.Update(ds_invetoryEdit))
// ShowMsg2(UpdatePanel1, "庫存量更新成功、料價更新成功");
// else
// ShowMsg2(UpdatePanel1, "庫存量更新成功、料價更新失敗");
// SearchData();
//}
#endregion
#region 刪除入庫紀錄單、入庫單內容、計畫分攤成本
string delete_stockRecord = "Delete ICS_StockIn_Record where stockInID = '" + stockinid + "'";
string delete_stockitem = "Delete ICS_StockIn_Item where stockInID = '" + stockinid + "'";
string delete_stockproject = "Delete ICS_Stock_Project where stockInID = '" + stockinid + "'";
bool suc = false;
suc = db.ExecuteStatement(delete_stockRecord);
suc = db.ExecuteStatement(delete_stockitem);
suc = db.ExecuteStatement(delete_stockproject);
if (suc)
{
ShowMsg2(UpdatePanel1, "刪除成功");
}
else
ShowMsg2(UpdatePanel1, "刪除失敗");
#endregion
SearchData();
//TODO:應該在刪除入庫資料後存一份入庫歷史資料
}
示例5: DeleteStockIn
//刪除入庫紀錄單、入庫單內容、計畫分攤成本
private void DeleteStockIn(string stockOutid)
{
string userid = (string)Session["UserID"];
SQLDB db = new SQLDB();
#region 刪除出庫紀錄單、出庫單內容
string delete_stockRecord = "Delete ICS_StockOut_Record where stockOutID = '" + stockOutid + "'";
string delete_stockitem = "Delete ICS_StockOut_Item where stockOutID = '" + stockOutid + "'";
bool suc = false;
suc = db.ExecuteStatement(delete_stockRecord);
suc = db.ExecuteStatement(delete_stockitem);
if (suc)
{
ShowMsg2(UpdatePanel1, "刪除成功");
}
else
ShowMsg2(UpdatePanel1, "刪除失敗");
#endregion
SearchData();
//TODO:應該在刪除入庫資料後存一份入庫歷史資料
}
示例6: btn_saveAll_Click
protected void btn_saveAll_Click(object sender, EventArgs e)
{
DataSet ds_StockInItem = (DataSet)Session["StockInItem"];
DataSet ds_StockProject = (DataSet)Session["ICS_Stock_Project"];
#region 驗證是否有輸入資料
if (ds_StockInItem == null || ds_StockProject == null)
{
ShowMsg2(UpdatePanel1, "請輸入資料");
return;
}
#endregion
#region 驗證物料成本跟計畫分攤成本有沒有相同
int stockcost = 0;
int projectcost = 0;
//驗證物料成本跟計畫分攤成本有沒有相同
if (ds_StockInItem != null)
{
for (int i = 0; i < ds_StockInItem.Tables[0].Rows.Count; i++)
{
stockcost += Convert.ToInt32(ds_StockInItem.Tables[0].Rows[i]["StockIn_Cost"].ToString());
}
}
if (ds_StockProject!= null)
{
for (int j = 0; j < ds_StockProject.Tables[0].Rows.Count; j++)
{
projectcost += Convert.ToInt32(ds_StockProject.Tables[0].Rows[j]["ContractCost"].ToString());
}
}
if (stockcost != projectcost)
{
ShowMsg2(UpdatePanel1, "入庫單總成本與計畫總成本不一致,請重新調整");
return;
}
#endregion
#region 新增入庫資料與計畫成本
string userid = (string)Session["UserID"];
string stockinid = "";
SQLDB db = new SQLDB();
DateTime now = DateTime.Now;
if (hidden_Action.Value == "add")
{
//將入庫單時間紀錄起來,之後利用入庫單時間與登入者帳號抓取入庫單編號
string Stockin_date = now.ToString("yyyy/MM/dd HH:mm:ss");
string insertstockrecord = "INSERT INTO ICS_StockIn_Record ([UpdateTime],[UpdateUser]) VALUES ('" + Stockin_date + "','" + userid + "')";
if (db.ExecuteStatement(insertstockrecord))
{
DataSet ds = db.Select("UpdateTime ='" + Stockin_date + "'and UpdateUser ='" + userid + "'", "", "ICS_StockIn_Record");
if (ds.Tables[0].Rows.Count > 0)
{
//抓到入庫單編號
stockinid = ds.Tables[0].Rows[0]["StockInID"].ToString();
//將入庫單編號塞到StockInItem裡
for (int i = 0; i < ds_StockInItem.Tables[0].Rows.Count; i++)
{
DataRow dr = ds_StockInItem.Tables[0].Rows[i];
dr["StockInID"] = stockinid;
dr["UpdateTime"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
dr["UpdateUser"] = userid;
}
//將入庫單編號塞到StockProject裡
for (int j = 0; j < ds_StockProject.Tables[0].Rows.Count; j++)
{
DataRow dr = ds_StockProject.Tables[0].Rows[j];
dr["StockInID"] = stockinid;
dr["UpdateTime"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
dr["UpdateUser"] = userid;
}
//刪除rowindex欄位
ds_StockInItem.Tables[0].Columns.Remove("rowindex");
ds_StockProject.Tables[0].Columns.Remove("rowindex");
DataSet DSChangeItem = ds_StockInItem.GetChanges();
DataSet DSChangeProject = ds_StockProject.GetChanges();
if (db.Insert(DSChangeItem))
ShowMsg2(UpdatePanel1, "入庫單內容新增成功");
else
ShowMsg2(UpdatePanel1, "入庫單內容新增失敗");
if (db.Insert(DSChangeProject))
ShowMsg2(UpdatePanel1, "入庫分攤成本新增成功");
else
ShowMsg2(UpdatePanel1, "入庫分攤成本新增失敗");
}
}
}
else//入庫單內容修改(目前暫時隱藏因為要考量的東西太多)
{
DataSet DSChangeItem = ds_StockInItem.GetChanges(DataRowState.Deleted);
DataSet DSChangeProject = ds_StockProject.GetChanges(DataRowState.Deleted);
if (DSChangeItem != null)
{
if (db.Update(DSChangeItem))
ShowMsg2(UpdatePanel1, "入庫單內容修改成功");
else
//.........这里部分代码省略.........
示例7: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
SQLDB db = new SQLDB();
string deviceKind = gv.Rows[e.RowIndex].Cells[1].Text;
TextBox checkcycle;
checkcycle = (TextBox)gv.Rows[e.RowIndex].Cells[2].Controls[0];
if (!IsNumeric(checkcycle.Text))
{
ShowMsg2(UpdatePanel1, "請輸入數字");
return;
}
//檢查更新是否成功
string updatestring = "Update CD_CheckCycle set cycle= '" + checkcycle.Text + "' where Devicekind = '" + deviceKind + "'";
if (db.ExecuteStatement(updatestring))
{
ShowMsg2(UpdatePanel1, "更新成功");
}
else
{
ShowMsg2(UpdatePanel1, "更新失敗");
}
gv.EditIndex = -1;
InitData();
SearchData();
}
示例8: gv_RowCommand
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cmd_delete")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gv.Rows[index];
string id = row.Cells[1].Text;
string delete = " delete VD_DOORSILL where ID = '" + id + "'";
SQLDB _operator = new SQLDB("VD_DOORSILL","KPT");
if (_operator.ExecuteStatement(delete))
{
ShowMsg(UpdatePanel1, "刪除成功");
SearchData();
}
}
}
示例9: gv_RowCommand
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "singleMapView")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gv.Rows[index];
string id = row.Cells[3].Text;
Response.Redirect("../MIS/mapViewer.aspx?type=Case&id=" + id);
}
if (e.CommandName == "WEdit")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gv.Rows[index];
string id = row.Cells[3].Text;
Response.Redirect("WarrantyNotifyAdd.aspx?act=edit&caseid=" + id);
}
if (e.CommandName == "WReturn")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gv.Rows[index];
string id = row.Cells[3].Text;
Response.Redirect("ReportReturnManage.aspx?act=return&id=" + id);
}
if (e.CommandName == "cmd_delete")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gv.Rows[index];
string id = row.Cells[3].Text;
string delete = " delete WarrantyNotify where CaseID = '" + id + "'";
SQLDB _operator = new SQLDB();
if (_operator.ExecuteStatement(delete))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert(\"刪除成功\")", true);
//Application["App_Invetory_MaterialType"] = CommonLib.GetMaterialType();
SearchData();
}
}
}
示例10: gv_RowCommand
//private void ExportTOExcel()
//{
// ExcelReport report = null;
// try
// {
// report = new ExcelReport("MIS/Region");
// DataSet ds = (DataSet)Session["DS_MIS"];
// for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
// {
// report.FillData(j + 3, 1, ds.Tables[0].Rows[j]["RegionName"].ToString(), 1);
// report.FillData(j + 3, 2, ds.Tables[0].Rows[j]["RegionCode"].ToString(), 1);
// }
// ScriptManager.RegisterStartupScript(this, this.GetType(), "newprintwindow2", "open_new_window(\"../Temp/" + report.Report() + "\");", true);
// }
// catch (Exception e)
// {
// if (report != null)
// {
// ScriptManager.RegisterStartupScript(this, this.GetType(), "newprintwindow2", "open_new_window(\"../Temp/" + report.Report() + "\");", true);
// }
// }
// finally
// {
// try
// {
// report.Close();
// }
// catch (Exception ex)
// {
// }
// }
//}
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cmd_delete")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gv.Rows[index];
string id = row.Cells[1].Text;
string delete = " delete ICS_Material_Type where materialTypeID = '" + id + "'";
SQLDB _operator = new SQLDB();
if (_operator.ExecuteStatement(delete))
{
ShowMsg(UpdatePanel1, "刪除成功");
Application["App_Invetory_MaterialType"] = CommonLib.GetMaterialType();
SearchData();
}
}
}