Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(CSaleBillData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into CSaleBill(");
            strSql.Append(@"docEntry,saleBillNo,saleBillDt,custNo,custNm,saleEmpNo,saleBillType,stockupBillNo,mark,financeBillNo,
                            isStockedByBill,instantState,AbsEntry,lineNum)");
            strSql.Append(" values (");
            strSql.Append(@"@docEntry,@saleBillNo,@saleBillDt,@custNo,@custNm,@saleEmpNo,@saleBillType,@stockupBillNo,@mark,@financeBillNo,
                            @isStockedByBill,@instantState,@AbsEntry,@lineNum)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@docEntry", SqlDbType.Int),
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@saleBillDt", SqlDbType.DateTime),
                    new SqlParameter("@custNo", SqlDbType.VarChar,20),
                    new SqlParameter("@custNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@saleEmpNo", SqlDbType.VarChar,20),
                    new SqlParameter("@saleBillType", SqlDbType.NVarChar,20),
                    new SqlParameter("@stockupBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@isStockedByBill", SqlDbType.Bit),
                    new SqlParameter("@instantState", SqlDbType.VarChar,10),
                    new SqlParameter("@AbsEntry", SqlDbType.Int),
                    new SqlParameter("@lineNum", SqlDbType.Int)
                };
            parameters[0].Value = model.docEntry;
            parameters[1].Value = model.saleBillNo;
            parameters[2].Value = model.saleBillDt == string.Empty ? null : model.saleBillDt;
            parameters[3].Value = model.custNo;
            parameters[4].Value = model.custNm;
            parameters[5].Value = model.saleEmpNo;
            parameters[6].Value = model.saleBillType;
            parameters[7].Value = model.stockupBillNo;
            parameters[8].Value = model.mark;
            parameters[9].Value = model.financeBillNo;
            parameters[10].Value = model.isStockedByBill;
            parameters[11].Value = model.instantState;
            parameters[12].Value = model.AbsEntry;
            parameters[13].Value = model.lineNum;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
    /// <summary>
    /// 删除提货单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        CStockUpBillBC stockUpBillBC = new CStockUpBillBC();
        CSaleBillBB saleBillBB = new CSaleBillBB();

        try
        {
            //获取选中的数据Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    int absEntry = 0;
                    CSaleBillData saleBillModel = new CSaleBillData();

                    saleBillModel = saleBillBB.GetModel(Convert.ToInt32(chkId.ValidationGroup));

                    if (saleBillModel != null && saleBillModel.instantState != "01")
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"销售订单已生成备货单,不允许删除!\");", true);
                        return;
                    }

                    //删除提货单信息
                    absEntry = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["absEntry"]);
                    stockUpBillBC.DeleteSaleBill(absEntry);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            stockUpBillBC.Dispose();
            saleBillBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
        else
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条记录!\");", true);
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(CSaleBillData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update CSaleBill set ");
            strSql.Append("docEntry=@docEntry,");
            strSql.Append("saleBillNo=@saleBillNo,");
            strSql.Append("saleBillDt=@saleBillDt,");
            strSql.Append("custNo=@custNo,");
            strSql.Append("custNm=@custNm,");
            strSql.Append("saleEmpNo=@saleEmpNo,");
            strSql.Append("saleBillType=@saleBillType,");
            strSql.Append("stockupBillNo=@stockupBillNo,");
            strSql.Append("mark=@mark,");
            strSql.Append("financeBillNo=@financeBillNo,");
            strSql.Append("isStockedByBill=@isStockedByBill,");
            strSql.Append("instantState=@instantState,");
            strSql.Append("AbsEntry=@AbsEntry,");
            strSql.Append("lineNum=@lineNum");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@docEntry", SqlDbType.Int),
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@saleBillDt", SqlDbType.DateTime),
                    new SqlParameter("@custNo", SqlDbType.VarChar,20),
                    new SqlParameter("@custNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@saleEmpNo", SqlDbType.VarChar,20),
                    new SqlParameter("@saleBillType", SqlDbType.NVarChar,20),
                    new SqlParameter("@stockupBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@isStockedByBill", SqlDbType.Bit),
                    new SqlParameter("@instantState", SqlDbType.VarChar,10),
                    new SqlParameter("@AbsEntry", SqlDbType.Int),
                    new SqlParameter("@lineNum", SqlDbType.Int)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.docEntry;
            parameters[2].Value = model.saleBillNo;
            parameters[3].Value = model.saleBillDt == string.Empty ? null : model.saleBillDt;
            parameters[4].Value = model.custNo;
            parameters[5].Value = model.custNm;
            parameters[6].Value = model.saleEmpNo;
            parameters[7].Value = model.saleBillType;
            parameters[8].Value = model.stockupBillNo;
            parameters[9].Value = model.mark;
            parameters[10].Value = model.financeBillNo;
            parameters[11].Value = model.isStockedByBill;
            parameters[12].Value = model.instantState;
            parameters[13].Value = model.AbsEntry;
            parameters[14].Value = model.lineNum;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Ejemplo n.º 4
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public CSaleBillData GetModel(string  no)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,docEntry,saleBillNo,saleBillDt,custNo,custNm,saleEmpNo,saleBillType,stockupBillNo,mark,financeBillNo,isStockedByBill,
                            instantState,AbsEntry,lineNum from CSaleBill");
            strSql.Append(" where saleBillNo = @saleBillNo ");
            SqlParameter[] parameters = {
                    new SqlParameter("@saleBillNo", no)
                };
            CSaleBillData model = new CSaleBillData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }

                if (row["docEntry"] != DBNull.Value)
                {
                    model.docEntry = Convert.ToInt32(row["docEntry"]);
                }

                if (row["saleBillNo"] != DBNull.Value)
                {
                    model.saleBillNo = Convert.ToString(row["saleBillNo"]);
                }
                if (row["saleBillDt"] != DBNull.Value)
                {
                    model.saleBillDt = Convert.ToString(row["saleBillDt"]);
                }
                if (row["custNo"] != DBNull.Value)
                {
                    model.custNo = Convert.ToString(row["custNo"]);
                }
                if (row["custNm"] != DBNull.Value)
                {
                    model.custNm = Convert.ToString(row["custNm"]);
                }
                if (row["saleEmpNo"] != DBNull.Value)
                {
                    model.saleEmpNo = Convert.ToString(row["saleEmpNo"]);
                }
                if (row["saleBillType"] != DBNull.Value)
                {
                    model.saleBillType = Convert.ToString(row["saleBillType"]);
                }
                if (row["stockupBillNo"] != DBNull.Value)
                {
                    model.stockupBillNo = Convert.ToString(row["stockupBillNo"]);
                }
                if (row["mark"] != DBNull.Value)
                {
                    model.mark = Convert.ToString(row["mark"]);
                }
                if (row["financeBillNo"] != DBNull.Value)
                {
                    model.financeBillNo = Convert.ToString(row["financeBillNo"]);
                }
                if (row["isStockedByBill"] != DBNull.Value)
                {
                    model.isStockedByBill = Convert.ToBoolean(row["isStockedByBill"]);
                }
                if (row["instantState"] != DBNull.Value)
                {
                    model.instantState = Convert.ToString(row["instantState"]);
                }
                if (row["AbsEntry"] != DBNull.Value)
                {
                    model.AbsEntry = Convert.ToInt32(row["AbsEntry"]);
                }
                if (row["lineNum"] != DBNull.Value)
                {
                    model.lineNum = Convert.ToInt32(row["lineNum"]);
                }

                return model;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(CSaleBillData model)
 {
     return this.saleBillDB.ModifyRecord(model);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(CSaleBillData model)
 {
     return this.saleBillDB.AddRecord(model);
 }