当前位置: 首页>>代码示例>>C#>>正文


C# SQLDB.Update方法代码示例

本文整理汇总了C#中SQLDB.Update方法的典型用法代码示例。如果您正苦于以下问题:C# SQLDB.Update方法的具体用法?C# SQLDB.Update怎么用?C# SQLDB.Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLDB的用法示例。


在下文中一共展示了SQLDB.Update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        Staff _operator = new Staff("Company");
        //物料名稱
        String my_MaterialName = txt_MaterialName.Text;
        //物料單位
        String my_MaterialUnit = txt_MaterialUnit.Text;
        //安全存量
        String my_MaterialSafeQuantity = txt_MaterialSafeQuantity.Text;
        //更新人員
        String USER;
        if (Session["UserID"] != null)
        {
            USER = Session["UserID"].ToString();
        }
        else
        {
            USER = "admin";
        }
        if (hidden_Action.Value == "add")
        {
            string sql = "INSERT INTO ICS_Material (MaterialName,MaterialUnit,MaterialSafeQuantity,UpdateTime,UpdateUser,MaterialTypeID) VALUES  ('" + my_MaterialName.ToString() + "','" + my_MaterialUnit.ToString() + "','" + my_MaterialSafeQuantity.ToString() + "',getdate(),'" + USER + "','" + cbo_materialType.SelectedValue + "')  ";
            if (_operator.ExecuteStatement(sql))
            {
                ShowMsg2(UpdatePanel1, "儲存成功");
                UpdateServerData(); //更新Application Data
                Response.AddHeader("Refresh", "3; url=Inventory_AQM.aspx");
            }
            else
            {
                ShowMsg2(UpdatePanel1, "儲存失敗");

            }
        }
        else
        {
            SQLDB db = new SQLDB();
            DataSet ds = new DataSet();
            ds = db.Select("NO = '"+hidden_Materialid.Value+"'","","ICS_Material");
            DataRow dr = ds.Tables[0].Rows[0];
            dr["MaterialName"] = my_MaterialName.ToString();
            dr["MaterialUnit"] = my_MaterialUnit.ToString();
            dr["MaterialSafeQuantity"] = my_MaterialSafeQuantity.ToString();
            dr["UpdateTime"] = DateTime.Now;
            dr["UpdateUser"] = USER;
            dr["MaterialTypeID"] = cbo_materialType.SelectedValue;
            DataSet DSChange = ds.GetChanges(DataRowState.Modified);
            //string sql = "UPDATE from ICS_Material (MaterialName,MaterialUnit,MaterialSafeQuantity,UpdateTime,UpdateUser,MaterialTypeID) VALUES  ('" + my_MaterialName.ToString() + "','" + my_MaterialUnit.ToString() + "','" + my_MaterialSafeQuantity.ToString() + "',getdate(),'" + USER + "','" + cbo_materialType.SelectedValue + "')  ";
            if (db.Update(DSChange))
            {
                ShowMsg2(UpdatePanel1, "儲存成功");
                UpdateServerData(); //更新Application Data
                Response.AddHeader("Refresh", "3; url=Inventory_AQM.aspx");
            }
            else
            {
                ShowMsg2(UpdatePanel1, "儲存失敗");

            }
        }

    }
开发者ID:hiway86,项目名称:PRS_KAO,代码行数:62,代码来源:Inventoryadd_A.aspx.cs

示例2: cmd_Save_Click1

 protected void cmd_Save_Click1(object sender, EventArgs e)
 {
     SQLDB deviceModel = new SQLDB("DeviceKind");
     if (hidden_Action.Value.Equals("add")) {
         DataSet DS = new DataSet();
         DataTable DT = new DataTable("DeviceKind");
         DT.Columns.Add("DeviceKindId");
         DT.Columns.Add("DeviceKind");
         DT.Columns.Add("DeviceKindName");
         DS.Tables.Add(DT);
         DataRow DR = DS.Tables[0].NewRow();
         DR["DeviceKindId"] = deviceModel.Select().Tables[0].Rows.Count + 1;
         DR["DeviceKind"] = txt_equipmentKind.Text;
         DR["DeviceKindName"] = txt_DeviceKindName.Text;
         DS.Tables[0].Rows.Add(DR);
         DataSet _changed = DS.GetChanges();
         if (deviceModel.Insert(_changed))
         {
             ReDirect("新增成功");
         }
         else {
             ReDirect("新增失敗");
         }
     }
     else if (hidden_Action.Value.Equals("edit")){
         DataSet ds = (DataSet)Session["DS_Mis"];
         if (ds != null){
             ds.Tables[0].Rows[0]["DeviceKind"] = txt_equipmentKind.Text;
             ds.Tables[0].Rows[0]["DeviceKindName"] = txt_DeviceKindName.Text;
             DataSet DSChange = ds.GetChanges(DataRowState.Modified);
             if (deviceModel.Update(DSChange))
             {
                 ReDirect("修改成功");
             }
             else {
                 ReDirect("修改失敗");
             }
         }
     }
 }
开发者ID:hiway86,项目名称:PRS_KAO,代码行数:40,代码来源:KindsOfEquipmentManage.aspx.cs

示例3: gv_stockOutitem_RowUpdating

    protected void gv_stockOutitem_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        SQLDB db = new SQLDB();
        //抓出庫單序號
        string stockoutitemid = gv_stockOutitem.DataKeys[e.RowIndex].Value.ToString();
        DataSet ds = db.Select("StockOutItemID = '" + stockoutitemid + "'", "", "ICS_StockOut_Item");
        if (ds.Tables[0].Rows.Count > 0)
        {
            TextBox reStockoutQuantity;
            reStockoutQuantity = (TextBox)gv_stockOutitem.Rows[e.RowIndex].Cells[7].Controls[0];
            ds.Tables[0].Rows[0]["ReConsumeQuantity"] = Convert.ToInt32(reStockoutQuantity.Text);
            DataSet DSChane = ds.GetChanges();
            if (db.Update(DSChane))
            {
                ShowMsg2(UpdatePanel1, "退繳成功");
            }

            gv_stockOutitem.EditIndex = -1;
            SearchStockItemProject(hid_stockOutid.Value);
        }

    }
开发者ID:hiway86,项目名称:PRS_KAO,代码行数:22,代码来源:App_Web_lm25o2vh.5.cs

示例4: 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
//.........这里部分代码省略.........
开发者ID:hiway86,项目名称:PRS_KAO,代码行数:101,代码来源:StockIn_ADM.aspx.cs

示例5: Button_add_click

    protected void Button_add_click(object sender, EventArgs e)
    {
        //通報者名稱
        string reportid = Session["UserID"].ToString();

        if (TextBox_FaultDescribe_add.Text.Length == 0)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('請輸入故障描述!');", true);
            return;
        }
        if (hidden_Action.Value == "edit")
        {
            SQLDB _operator = new SQLDB();
            DataSet ds_edit = _operator.Select("CaseID = '" + hidden_Caseid.Value + "'", "", "WarrantyNotify");
            DataRow dr = ds_edit.Tables[0].Rows[0];
            dr["FaultModel"] = this.DropDownList_FaultModel_add.Text;
            dr["FaultDescribe"] = this.TextBox_FaultDescribe_add.Text;
            dr["RepeatNotify"] = this.TextBox_RepeatNotify_add.Text;
            dr["WarrantyCompany"] = this.DropDownList_WarrantyCompany_add.SelectedItem.ToString();
            dr["WarrantyContract"] = int.Parse(this.DropDownList_WarrantyContract_add.SelectedValue);
            dr["NotifyDate"] = Convert.ToDateTime(this.TextBox_NotifyDate_add.Text);
             if (this.DropDownList_ContractCombineNum.SelectedIndex > 0)
            {
                dr["ContractCombineNum"] = int.Parse(this.DropDownList_ContractCombineNum.SelectedItem.ToString());
            }

             switch (this.DropDownList_RepairDateOption_add.SelectedIndex)
             {
                 case 0:
                     //修復日期選項
                     ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('請點選修復日期選項!');", true);
                     return;
                 //break;
                 case 1:
                     dr["RepairDateOption"] = 1;
                     break;
                 case 2:
                     dr["RepairDateOption"] = 2;
                     break;
                 case 3:
                     dr["RepairDateOption"] = 3;
                     dr["RepairDeadline"] = Convert.ToDateTime(this.TextBox_RepairDeadline_add.Text);
                     break;
             }
             DataSet DSChange = ds_edit.GetChanges(DataRowState.Modified);
             if (_operator.Update(DSChange))
             {
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('修改成功');", true);
                 UpdateServerData();
             }
        }
        else
        {
            WarrantyNotify wn = new WarrantyNotify();
            wn.DeviceID = this.TextBox_DeviceID_add.Text;
            wn.FaultModel = this.DropDownList_FaultModel_add.Text;
            wn.FaultDescribe = this.TextBox_FaultDescribe_add.Text;
            wn.RepeatNotify = this.TextBox_RepeatNotify_add.Text;
            wn.WarrantyCompany = this.DropDownList_WarrantyCompany_add.SelectedItem.ToString();
            if (this.DropDownList_WarrantyContract_add.SelectedIndex > 0)
            {
                wn.WarrantyContract = int.Parse(this.DropDownList_WarrantyContract_add.SelectedValue);
            }
            wn.NotifyDate = Convert.ToDateTime(this.TextBox_NotifyDate_add.Text);
            wn.NotifyConfirm = false;
            if (this.DropDownList_ContractCombineNum.SelectedIndex > 0)
            {
                wn.ContractCombineNum = int.Parse(this.DropDownList_ContractCombineNum.SelectedItem.ToString());
            }

            wn.Status = "維修中";


            switch (this.DropDownList_RepairDateOption_add.SelectedIndex)
            {
                case 0:
                    //修復日期選項
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('請點選修復日期選項!');", true);
                    return;
                //break;
                case 1:
                    wn.RepairDateOption = 1;
                    break;
                case 2:
                    wn.RepairDateOption = 2;
                    break;
                case 3:
                    wn.RepairDateOption = 3;
                    wn.RepairDeadline = Convert.ToDateTime(this.TextBox_RepairDeadline_add.Text);
                    break;
            }

            wn.Add();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('新增成功');", true);
            UpdateServerData();
        }

        if (chk_isSendMail.Checked)
        {
            try
//.........这里部分代码省略.........
开发者ID:hiway86,项目名称:PRS_KAO,代码行数:101,代码来源:App_Web_yxas322n.3.cs


注:本文中的SQLDB.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。