public void waitStorge(string label, string goodsName, int Qty, string userId)
        {
            InsertData(label, goodsName, Qty, 1, userId);
            SelectCommandBuilder s = new SelectCommandBuilder();
            int    count           = Convert.ToInt32(s.ExecuteScalar("select count(*) from Material_control_process where label = '" + label + "' and process_id = 1"));
            string sql             = string.Empty;

            if (count != 0)
            {
                UpdateCommandBuilder up = new UpdateCommandBuilder();
                sql = "update Material_control_process set InQty = InQty + " + Qty + " ,CurrQty = CurrQty + " + Qty + " where label = '" + label + "' and process_id = 1";
            }
            else
            {
                InsertCommandBuilder ins = new InsertCommandBuilder("Material_control_process");
                ins.InsertColumn("label", label);
                ins.InsertColumn("goods_name", goodsName);
                ins.InsertColumn("process_id", 1);
                ins.InsertColumn("InQty", Qty);
                ins.InsertColumn("OutQty", 0);
                ins.InsertColumn("CurrQty", Qty);
                ins.InsertColumn("in_date", "getDate()");
                sql = ins.getInsertCommand();
            }
            new InsertCommandBuilder().ExecuteNonQuery(sql);
        }
        private void DoMain(string[] aList)
        {
            List <string> Alist = new List <string>();

            str_bill_id = CommadMethod.getNextId("00000000", "");
            InsertCommandBuilder insert3 = new InsertCommandBuilder("pre_str_in_bill");

            insert3.InsertColumn("str_in_bill_id", str_bill_id);
            insert3.InsertColumn("str_in_type_id", "C");
            insert3.InsertColumn("str_in_bill_no", aList[0].Trim() + aList[2].Trim().Substring(2, 6) + Convert.ToInt32(aList[3].Trim()).ToString());
            insert3.InsertColumn("operator_date", "getdate()");
            insert3.InsertColumn("str_in_date", "getdate()");
            insert3.InsertColumn("store_id", "03");//store_id);//暂时固定为03
            insert3.InsertColumn("create_user", "0000");
            insert3.InsertColumn("operator_id", "0000");
            //insert3.InsertColumn("come_from", aList[1]);
            insert3.InsertColumn("islocal", "y");
            //insert.InsertColumn("is_state", "N");
            Alist.Add(insert3.getInsertCommand());
            InsertCommandBuilder ins = new InsertCommandBuilder("pre_str_in_bill_detail");

            ins.InsertColumn("batch_id", CommadMethod.getNextId("00000000", ""));
            ins.InsertColumn("str_in_bill_id", str_bill_id);
            ins.InsertColumn("goods_id", new SelectCommandBuilder().ExecuteDataTable("select goods_id from goods where goods_name='" + goodsName + "'").Rows[0][0].ToString());
            ins.InsertColumn("qty", Qty);
            ins.InsertColumn("hwh", hwh);
            ins.InsertColumn("pch", aList[2]);
            Alist.Add(ins.getInsertCommand());
            ins.ExcutTransaction(Alist);
            sList.Insert(0, AppendDateTime("部番:" + goodsName + "  数量:" + Qty));
            sList.Insert(0, AppendDateTime("OK,条码???"));
        }
        public void print(string label, string goodsName, int Qty, string userId)
        {
            InsertData(label, goodsName, Qty, 3, userId);
            SelectCommandBuilder s = new SelectCommandBuilder();
            int    count           = Convert.ToInt32(s.ExecuteScalar("select count(*) from Material_control_process where label = '" + label + "' and process_id = 3"));
            string sql             = string.Empty;

            if (count != 0)
            {
                sql = "update Material_control_process set OutQty = InQty + " + Qty + " ,CurrQty = CurrQty + " + Qty + " where label = '" + label + "' and process_id = 3 ";
            }
            else
            {
                InsertCommandBuilder ins = new InsertCommandBuilder("Material_control_process");
                ins.InsertColumn("label", label);
                ins.InsertColumn("goods_name", goodsName);
                ins.InsertColumn("process_id", 3);
                ins.InsertColumn("InQty", Qty);
                ins.InsertColumn("OutQty", 0);
                ins.InsertColumn("CurrQty", Qty);
                ins.InsertColumn("in_date", "getDate()");
                sql = ins.getInsertCommand();
            }
            string        sql1 = "update Material_control_process set OutQty = OutQty + " + Qty + " ,CurrQty = CurrQty - " + Qty + " where label = '" + label + "' and process_id = 1 ";
            List <string> list = new List <string>();

            list.Add(sql);
            list.Add(sql1);
            new InsertCommandBuilder().ExcutTransaction(list);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (ddlMaterialStock.SelectedItem.Value == "0")
            {
                Response.Write("<script>alert('请选择仓位点')</script>");
                return;
            }
            if (txtNo.Text.Trim().Equals(string.Empty))
            {
                Response.Write("<script>alert('请输入单号')</script>");
                return;
            }
            DateTime             date            = DateTime.Now;
            string               IdLeftPart      = "HC" + date.Year.ToString().Substring(2, 2) + date.Month.ToString().PadLeft(2, '0') + date.Day.ToString().PadLeft(2, '0');
            string               str_out_bill_id = CommadMethod.getNextId(IdLeftPart, "");
            InsertCommandBuilder ins             = new InsertCommandBuilder(constr, "pre_str_out_bill");

            ins.InsertColumn("str_out_bill_id", str_out_bill_id);
            ins.InsertColumn("str_out_bill_no", txtNo.Text.Trim().ToUpper());
            ins.InsertColumn("str_out_type_id", rbtType.SelectedItem.Value);
            ins.InsertColumn("str_out_date", txtDate.Text);
            ins.InsertColumn("store_id", ddlMaterialStock.SelectedItem.Value);
            ins.InsertColumn("operator_id", "0000");
            ins.InsertColumn("remark", txtRemark.Text.Trim());
            ins.InsertColumn("operator_date", txtDate.Text);
            ins.InsertColumn("come_to", rbtType.SelectedItem.Text);
            ins.InsertColumn("islocal", "Y");
            ins.InsertColumn("save_state", "Y");
            sql     = ins.getInsertCommand();
            No      = txtNo.Text.Trim();
            bill_id = str_out_bill_id;
            Server.Transfer("StockOut_AddData.aspx");
        }
Esempio n. 5
0
        public IInsertCommandBeforeOrAfterTargetSyntax InsertPartialView(string viewName, object model)
        {
            var commandBuilder = new InsertCommandBuilder(this);

            commandBuilder.SetPartialView(viewName, model);
            return(commandBuilder);
        }
Esempio n. 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (insList.Count == 0)
            {
                Response.Write("<script>alert('无数据保存,请先添加数据')</script>");
                return;
            }
            List <string> sqlList = new List <string>();

            sqlList.Add(ViewState["sql"].ToString());
            DateTime date       = DateTime.Now;
            string   IdLeftPart = "PH" + date.Year.ToString().Substring(2, 2) + date.Month.ToString().PadLeft(2, '0') + date.Day.ToString().PadLeft(2, '0');

            for (int i = 0; i < insList.Count; i++)
            {
                string Id = CommadMethod.getNextId(IdLeftPart, "");
                InsertCommandBuilder ins = new InsertCommandBuilder(constr, "pre_str_in_bill_detail");
                ins.InsertColumn("str_in_bill_id", ViewState["str_in_bill_id"].ToString());
                ins.InsertColumn("batch_id", Id);
                ins.InsertColumn("goods_id", new SelectCommandBuilder(constr, "").ExecuteDataTable("select goods_id from goods_tmp where goods_name = '" + insList[i].goods_name + "'").Rows[0][0].ToString().Trim());
                ins.InsertColumn("qty", insList[i].Qty.ToString());
                ins.InsertColumn("pch", insList[i].batch);
                ins.InsertColumn("can_sale", "Y");
                ins.InsertColumn("hwh", insList[i].goodsPost);
                sqlList.Add(ins.getInsertCommand());
            }
            int count = new InsertCommandBuilder(constr, "").ExcutTransaction(sqlList);

            if (count != 0)
            {
                Response.Write("<script>alert('保存成功')</script>");
                insList.Clear();
                Response.Redirect("StockIn_SaveOk.aspx");
            }
        }
Esempio n. 7
0
        public void ImportData(string tableName, DataTable dataTable)
        {
            // Don't continue if no data passed
            if (dataTable == null)
            {
                throw new ArgumentNullException(nameof(dataTable));
            }

            CommandExecutor      commandExecutor = new CommandExecutor();
            InsertCommandBuilder insertCommandBuilder;

            // To prevent attempting to import deleted rows, need to accept changes on the passed datatable first
            dataTable.AcceptChanges();

            // Run an INSERT command for each row
            foreach (DataRow row in dataTable.Rows)
            {
                insertCommandBuilder = new InsertCommandBuilder();
                insertCommandBuilder.SetTableName(tableName);

                // Construct INSERT command
                for (int i = 0; i < dataTable.Columns.Count; i++)
                {
                    if (dataTable.Columns[i].ColumnName == "_id")
                    {
                        continue;
                    }

                    insertCommandBuilder.AddField(dataTable.Columns[i].ColumnName, row[i]);
                }

                // Insert into database
                commandExecutor.ExecuteNonQuery(insertCommandBuilder.ToString());
            }
        }
Esempio n. 8
0
        protected List <string> getSQLList(GridView dgv)
        {
            for (int i = 0; i < dgv.Rows.Count; i++)
            {
                for (int j = 0; j < dgv.Rows[i].Cells.Count; j++)
                {
                    if (dgv.Rows[i].Cells[j].Text == "&nbsp;")
                    {
                        dgv.Rows[i].Cells[j].Text = "";
                    }
                }
            }
            List <string>        sList = new List <string>();
            InsertCommandBuilder ins   = new InsertCommandBuilder("Client_FC");

            for (int i = 0; i < dgv.Rows.Count; i++)
            {
                ins.InsertColumn("NO_id", "1");
                ins.InsertColumn("goods_name", dgv.Rows[i].Cells[0].Text.ToString());
                //ins.InsertColumn("lb1_id", dgv.Rows[i].Cells[1].Text.ToString());
                ins.InsertColumn("client_id", dgv.Rows[i].Cells[2].Text.ToString());
                ins.InsertColumn("FC_qty", dgv.Rows[i].Cells[3].Text.ToString());
                ins.InsertColumn("delivery_date", Convert.ToDateTime(dgv.Rows[i].Cells[4].Text).ToString("yyyy-MM-dd HH:mm:ss"));
                ins.InsertColumn("delivery_no", dgv.Rows[i].Cells[5].Text.ToString());
                ins.InsertColumn("remark", txtRemark.Text.Trim());
                ins.InsertColumn("version_no", txtVer_No.Text.Trim());
                ins.InsertColumn("status", "N");
                ins.InsertColumn("operation_date", "getDate()");
                ins.InsertColumn("operator_id", HttpContext.Current.Request.Cookies["cookie"].Values["id"]);
                sList.Add(ins.getInsertCommand());
                ins.CommandClear();
            }
            return(sList);
        }
Esempio n. 9
0
        public int Insert(Type itemType, object item, string tableName)
        {
            InsertCommandBuilder inserter = InsertCommandBuilder.Create(itemType);
            DbCommand            command  = inserter.Build(item, tableName, _database, Connection, Transaction);

            command.ExecuteNonQuery();
            return((int)inserter.GetKey(command));
        }
Esempio n. 10
0
        public static InsertCommandBuilder Insert(this IDataContext context, string table)
        {
            var builder = new InsertCommandBuilder(context);

            builder.From(table);

            return(builder);
        }
Esempio n. 11
0
        protected List <string> getSQLList(GridView dgv)
        {
            int           index = 0;
            List <string> sList = new List <string>();

            try
            {
                InsertCommandBuilder insert = new InsertCommandBuilder(constr, "Goods_Up");
                for (int i = 0; i < dgv.Rows.Count; i++)
                {
                    string goods_name = dgv.Rows[i].Cells[0].Text.ToString().ToUpper();
                    index = i;
                    SelectCommandBuilder s = new SelectCommandBuilder(constr, "goods_tmp");
                    s.SelectColumn("Count(goods_id)");
                    s.ConditionsColumn("goods_name", goods_name.Trim());
                    s.getSelectCommand();
                    int count = Convert.ToInt32(s.ExecuteScalar());
                    if (count == 0)
                    {
                        sList.Add(InsertData(
                                      dgv.Rows[i].Cells[0].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[1].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[2].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[3].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[4].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[5].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[6].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[7].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[8].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[9].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[10].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[11].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[12].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[13].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[14].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[15].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[16].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[17].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[18].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[19].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[20].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[21].Text.ToString().ToUpper().IndexOf('%') != -1 ? (Convert.ToDecimal(dgv.Rows[i].Cells[21].Text.ToString().ToUpper().Split('%')[0]) / 100).ToString() : (Convert.ToDecimal(dgv.Rows[i].Cells[21].Text.ToString().ToUpper()) / 100).ToString(),
                                      dgv.Rows[i].Cells[22].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[23].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[24].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[25].Text.ToString().ToUpper(),
                                      ddlCustomer.SelectedItem.Value
                                      ));
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('系统出现以下错误:" + ex.Message + "!')</script>");
                gvExcel.Rows[index].BackColor = System.Drawing.Color.Red;
            }
            return(sList);
        }
Esempio n. 12
0
    public void Build_Throws_When_FieldValues_Are_Empty()
    {
        // Arrange
        var input = new InsertCommandBuilder().Into("MyTable").AddFieldNames("Field1", "Field2", "Field3");

        // Act & Assert
        input.Invoking(x => x.Build())
        .Should().Throw <InvalidOperationException>()
        .WithMessage("field values are missing");
    }
Esempio n. 13
0
    public void Build_Throws_When_TableName_Is_Missing()
    {
        // Arrange
        var input = new InsertCommandBuilder();

        // Act & Assert
        input.Invoking(x => x.Build())
        .Should().Throw <InvalidOperationException>()
        .WithMessage("table name is missing");
    }
Esempio n. 14
0
        public IInsertCommandBeforeOrAfterTargetSyntax InsertContent(PartialViewResult partialViewResult)
        {
            if (partialViewResult == null)
            {
                throw new ArgumentNullException("partialViewResult");
            }

            var commandBuilder = new InsertCommandBuilder(this);

            commandBuilder.SetContent(partialViewResult);
            return(commandBuilder);
        }
Esempio n. 15
0
    public void Build_Throws_When_FieldNames_And_FieldValues_Count_Are_Not_Equal()
    {
        // Arrange
        var input = new InsertCommandBuilder().Into("MyTable")
                    .AddFieldNames(new[] { "Field1", "Field2", "Field3" }.AsEnumerable())
                    .AddFieldValues(new[] { "Value1", "Value2" }.AsEnumerable());

        // Act & Assert
        input.Invoking(x => x.Build())
        .Should().Throw <InvalidOperationException>()
        .WithMessage("field name count should be equal to field value count");
    }
Esempio n. 16
0
        public IInsertCommandBeforeOrAfterTargetSyntax InsertContent(string html)
        {
            if (html == null)
            {
                throw new ArgumentNullException("html");
            }

            var commandBuilder = new InsertCommandBuilder(this);

            commandBuilder.SetContent(html);
            return(commandBuilder);
        }
Esempio n. 17
0
        public void  Test()
        {
            DBConnection         connection = TestSettings.CreateConnection();
            InsertCommandBuilder builder    = new InsertCommandBuilder(connection);

            builder.TableName = "Table1";
            builder.AddParameter("value", "1");
            IDbCommand command = builder.Build();

            Assert.IsNotNull(command);
            Assert.AreEqual(1, connection.ExecuteNonQuery(command));
        }
Esempio n. 18
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (ddlMaterialStock.SelectedItem.Value == "0")
            {
                Response.Write("<script>alert('请选择仓位点')</script>");
                return;
            }
            if (txtNo.Text.Trim().Equals(string.Empty))
            {
                Response.Write("<script>alert('请输入单号')</script>");
                txtNo.Focus();
                return;
            }
            if (rbtType.SelectedIndex != 0)
            {
                if (txtgoodsName.Text == string.Empty)
                {
                    Response.Write("<script>alert('请输入部番')</script>");
                    txtgoodsName.Focus();
                    return;
                }
                if (gvList.SelectedIndex == -1)
                {
                    Response.Write("<script>alert('没有选择计划')</script>");
                    return;
                }
            }
            DateTime             date           = DateTime.Now;
            string               IdLeftPart     = "HC" + date.Year.ToString().Substring(2, 2) + date.Month.ToString().PadLeft(2, '0') + date.Day.ToString().PadLeft(2, '0');
            string               str_in_bill_id = CommadMethod.getNextId(IdLeftPart, "");
            InsertCommandBuilder ins            = new InsertCommandBuilder(constr, "pre_str_in_bill");

            ins.InsertColumn("str_in_bill_id", str_in_bill_id);
            ins.InsertColumn("str_in_bill_no", txtNo.Text);
            ins.InsertColumn("operator_id", "0000");
            ins.InsertColumn("operator_date", txtDate.Text);
            ins.InsertColumn("store_id", ddlMaterialStock.SelectedItem.Value.Trim());
            ins.InsertColumn("str_in_type_id", rbtType.SelectedItem.Value);
            ins.InsertColumn("come_from", rbtType.SelectedIndex == 0 ? rbtType.SelectedItem.Text.Trim() : gvList.SelectedRow.Cells[1].Text.Trim());
            ins.InsertColumn("is_state", "Y");
            sql     = ins.getInsertCommand();
            No      = txtNo.Text.Trim();
            bill_id = str_in_bill_id;
            if (rbtType.SelectedIndex == 0)
            {
                Server.Transfer("StockIn_AddData.aspx");
            }
            else if (rbtType.SelectedIndex == 1)
            {
                DId = gvList.SelectedRow.Cells[1].Text.Trim();
                Server.Transfer("StockIn_AddDictateData.aspx");
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (checkInput() != true)
            {
                return;
            }
            Id = CommadMethod.getNextId("Fix" + DateTime.Now.ToString("yyyyMMdd"), "").Trim();
            string docType = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower();

            imgId = Id + docType;
            InsertCommandBuilder ins = new InsertCommandBuilder("Repair_records");

            ins.InsertColumn("id", Id);
            ins.InsertColumn("eqp_no", tags.Text);
            ins.InsertColumn("rely_date", txtDate.Text);
            ins.InsertColumn("repair_time", Convert.ToDecimal(txtHours.Text));
            ins.InsertColumn("repair_record", txtRecords.Text);
            ins.InsertColumn("type", ddlType.SelectedItem.Text);
            ins.InsertColumn("rely_dept", ddlDept.SelectedItem.Text);
            string person = string.Empty;

            for (int i = 0; i < cblPerson.Items.Count; i++)
            {
                if (cblPerson.Items[i].Selected == true)
                {
                    person += cblPerson.Items[i].Text + ",";
                }
            }
            if (!string.IsNullOrEmpty(txtPerson.Text))
            {
                person += txtPerson.Text;
            }
            else
            {
                person = person.Substring(0, person.Length - 1);
            }
            ins.InsertColumn("repairman", person);
            ins.InsertColumn("create_date", "getdate()");
            ins.InsertColumn("doc_url", imgId);
            ins.getInsertCommand();
            int count = ins.ExecuteNonQuery();

            if (count != 0)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('添加成功')</script>", false);
                uploadImg();
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('添加失败')</script>", false);
            }
        }
        private static void InsertData(string label, string goodsName, int Qty, int areaId, string userId)
        {
            InsertCommandBuilder ins = new InsertCommandBuilder("Material_control");

            ins.InsertColumn("label", label);
            ins.InsertColumn("goods_name", goodsName);
            ins.InsertColumn("process_id", areaId);
            ins.InsertColumn("qty", Qty);
            ins.InsertColumn("operate_time", "getDate()");
            ins.InsertColumn("operator", userId);
            ins.getInsertCommand();
            ins.ExecuteNonQuery();
        }
Esempio n. 21
0
        public int excutInsert(string Barcode, string goods_name, int qty, string pdate, string sn, string customerID)
        {
            InsertCommandBuilder insert = new InsertCommandBuilder("BarCodeRecords");

            insert.InsertColumn("Barcode", Barcode);
            insert.InsertColumn("goods_name", goods_name);
            insert.InsertColumn("qty", qty);
            insert.InsertColumn("pdate", pdate);
            insert.InsertColumn("sn", sn);
            insert.InsertColumn("customerId", customerID);
            insert.InsertColumn("create_date", "getdate()");
            insert.getInsertCommand();
            return(insert.ExecuteNonQuery());
        }
Esempio n. 22
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string userID            = TextBox1.Text;
            string department        = TextBox2.Text;
            string name              = TextBox3.Text;
            InsertCommandBuilder icd = new InsertCommandBuilder();
            string sqlinsert         = @"insert into shatter_Parts_Password (userid,department,name)
                               values('" + userID + "','" + department + "','" + name + "')";

            Debug.WriteLine(sqlinsert);

            icd.ExecuteNonQuery(sqlinsert);
            Response.Redirect("UserManage.aspx");
        }
Esempio n. 23
0
    public void Build_Generates_Command_With_Output()
    {
        // Arrange
        var input = new InsertCommandBuilder().Into("MyTable")
                    .AddFieldNames(new[] { "Field1", "Field2", "Field3" }.AsEnumerable())
                    .AddFieldValues(new[] { "\"Value1\"", "\"Value2\"", "\"Value3\"" }.AsEnumerable())
                    .AddOutputFields(new[] { "INSERTED.Field1", "INSERTED.Field2", "INSERTED.Field3" }.AsEnumerable());

        // Act
        var actual = input.Build();

        // Assert
        actual.Operation.Should().Be(DatabaseOperation.Insert);
        actual.CommandText.Should().Be("INSERT INTO MyTable(Field1, Field2, Field3) OUTPUT INSERTED.Field1, INSERTED.Field2, INSERTED.Field3 VALUES(\"Value1\", \"Value2\", \"Value3\")");
    }
Esempio n. 24
0
        /// <summary>
        /// Creates the insert command.
        /// </summary>
        /// <returns></returns>
        private void CreateInsertCommand()
        {
            var builder = new InsertCommandBuilder(_connection.Factory);

            builder.TableName = TableName;

            foreach (PropertyInfo field in _fields)
            {
                builder.AddParameter(field.Name, field.PropertyType);
            }


            _insertCommand = builder.Build();
            //insertCommand.Prepare();
        }
Esempio n. 25
0
    public void Can_Clear_Builder()
    {
        // Arrange
        var input = new InsertCommandBuilder().Into("MyTable")
                    .AddFieldNames("Field1", "Field2", "Field3")
                    .AddFieldValues("@Field1", "@Field2", "@Field3")
                    .AppendParameters(new { Field1 = "Value1", Field2 = "Value2", Field3 = "Value3" });

        // Act
        input.Clear();

        // Assert
        input.Invoking(x => x.Build())
        .Should().Throw <InvalidOperationException>()
        .WithMessage("table name is missing");
    }
        public void AddParameter()
        {
            InsertCommandBuilder builder = new InsertCommandBuilder(TestSettings.CreateConnection());

            builder.TableName = "Table1";
            builder.AddParameter("p1", DbType.Date);
            builder.AddParameter("p2", typeof(DateTime));
            builder.AddParameter("p3", 1);
            builder.AddParameter("p4", "par4", true);
            IDbCommand command = builder.Build();

            Assert.AreEqual(command.CommandType, CommandType.Text);
            Assert.IsNotNull(command.Parameters["@p1"]);
            Assert.IsNotNull(command.Parameters["@p2"]);
            Assert.IsNotNull(command.Parameters["@p3"]);
            Assert.IsNotNull(command.Parameters["@par4"]);
        }
        protected void btnReConAll_Click(object sender, EventArgs e)
        {
            List <string> sqlList = new List <string>();

            for (int i = 0; i < gvData.Rows.Count; i++)
            {
                string sql = "update tmp_pk_bill set status ='N' where bill_id ='" + gvData.Rows[i].Cells[0].Text.Trim() + "' ";
                sqlList.Add(sql);
            }
            int c**t = new InsertCommandBuilder().ExcutTransaction(sqlList);

            if (c**t != 0)
            {
                Response.Write("<script>alert('" + Resources.Resource.alterOk + "!')</script>");
                btnSearch_Click(sender, e);
            }
        }
Esempio n. 28
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (gvData.SelectedIndex == -1)
            {
                Response.Write("<script>alert('" + Resources.Resource.alterwxz + "!')</script>");
                return;
            }
            string sql       = "delete from pd where bill_id='" + ViewState["billId"].ToString() + "'";
            string detailsql = "delete from pd_detail where bill_id='" + ViewState["billId"].ToString() + "'";
            int    c**t      = new InsertCommandBuilder().ExecuteNonQuery(sql);

            c**t += new InsertCommandBuilder().ExecuteNonQuery(detailsql);
            if (c**t != 0)
            {
                Response.Write("<script>alert('" + Resources.Resource.alterOk + "!')</script>");
                btnSearch_Click(sender, e);
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!UIValidtion.Create()
                .Null(txtName, "名称")
                .Len(2, 16)
                .My(p => {
                if (Symbol.TypeExtensions.Convert <int>(Program.DataContext.ExecuteScalar("select top 1 [Id] from [Funds] where [UserId]=@p1 and [Name]=@p2", Program.CurrentUser.Id, p.LastValue), 0) > 0)
                {
                    p.Return(false)
                    .Msg("此资金库已经存在!")
                    .LastControl.Focus();
                }
            })
                .Null(txtMoney, "余额")
                .NumDec()
                .Null(txtOrder, "顺序")
                .NumDec()
                .Null(txtBankName, "银行", chkIsBank.Checked)
                .Len(2, 16)
                .Null(txtCardNumber, "卡号", chkIsBank.Checked)
                .Len(2, 32)
                .Result)
            {
                return;
            }


            _model = new Funds()
            {
                UserId     = Program.CurrentUser.Id,
                Name       = txtName.Text,
                Money      = Symbol.TypeExtensions.Convert <decimal>(txtMoney.Text, 0M),
                Order      = Symbol.TypeExtensions.Convert <double>(txtOrder.Text, 0D),
                IsBank     = chkIsBank.Checked,
                BankName   = txtBankName.Text,
                CardNumber = txtCardNumber.Text,
            };
            using (InsertCommandBuilder builder = new InsertCommandBuilder("Funds")) {
                builder.Fields.SetValues(_model);
                builder.Fields.Remove("Id");
                _model.Id = Symbol.TypeExtensions.Convert <int>(Program.DataContext.ExecuteScalar(builder.CommandText, builder.Values), 0);
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
Esempio n. 30
0
        protected void btnCannel_Click(object sender, EventArgs e)
        {
            string        sql1  = "delete from pre_str_out_bill where str_out_bill_id='" + ViewState["Id"].ToString() + "'";
            string        sql2  = "delete from pre_str_out_bill_detail where str_out_bill_id='" + ViewState["Id"].ToString() + "'";
            List <string> sList = new List <string>();

            sList.Add(sql1);
            sList.Add(sql2);
            int count = new InsertCommandBuilder(constr, "").ExcutTransaction(sList);

            if (count != 0)
            {
                Response.Redirect("StockIn_SaveOk.aspx", false);
            }
            else
            {
                Response.Write("<script>alert('操作失败')</script>");
            }
        }