Exemplo n.º 1
0
        /// <summary>
        /// 得到新增sql
        /// </summary>
        public string GetAddBillSQL(OtherInOrder OtherInOrder)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OtherInOrder(");
            strSql.Append("OtherInOrderGuid,OtherInOrderID,OtherInOrderDate,InStorage,StoragePerson,QualityPerson,BatchNo,Remark,CreateGuid,CreateDate,CheckGuid,CheckDate");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + OtherInOrder.OtherInOrderGuid + "',");
            strSql.Append("'" + OtherInOrder.OtherInOrderID + "',");
            strSql.Append("'" + OtherInOrder.OtherInOrderDate + "',");
            strSql.Append("'" + OtherInOrder.InStorage + "',");
            strSql.Append("'" + OtherInOrder.StoragePerson + "',");
            strSql.Append("'" + OtherInOrder.QualityPerson + "',");
            strSql.Append("'" + OtherInOrder.BatchNo + "',");
            strSql.Append("'" + OtherInOrder.Remark + "',");
            strSql.Append("'" + OtherInOrder.CreateGuid + "',");
            strSql.Append("'" + OtherInOrder.CreateDate + "',");
            strSql.Append("'" + OtherInOrder.CheckGuid + "',");
            if (OtherInOrder.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null");
            }
            else
            {
                strSql.Append("'" + OtherInOrder.CheckDate + "'");
            }
            strSql.Append(")");
            return(strSql.ToString());
        }
Exemplo n.º 2
0
        ///<summary>
        /// 保存数据
        /// </summary>
        /// <param name="pObj">信息集实体类</param>
        /// <returns>返回保存成功(true)或失败(false)</returns>
        public void SaveBill(OtherInOrder OtherInOrder, List <OtherInOrderDetail> OtherInOrderDetail)
        {
            CommonInterface pComm = CommonFactory.CreateInstance(CommonData.sql);

            try
            {
                pComm.BeginTrans();

                //保存单据主表数据
                //先删除主表数据
                string strDeleteSql = "Delete from OtherInOrder where  OtherInOrderGuid='" + OtherInOrder.OtherInOrderGuid + "'";
                pComm.Execute(strDeleteSql);

                //插入主表数据
                string strInsertSql = GetAddBillSQL(OtherInOrder);
                pComm.Execute(strInsertSql);


                //删除明细表
                strDeleteSql = "Delete from OtherInOrderDetail where  OtherInOrderGuid='" + OtherInOrder.OtherInOrderGuid + "'";
                pComm.Execute(strDeleteSql);

                //插入明细表数据
                for (int i = 0; i < OtherInOrderDetail.Count; i++)
                {
                    strInsertSql = GetAddBillDetailSQL(OtherInOrderDetail[i]);
                    pComm.Execute(strInsertSql);
                }


                pComm.CommitTrans();
            }
            catch (Exception e)
            {
                pComm.RollbackTrans();
                pComm.Close();
                throw e;
            }
        }