Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(VAN_OA.Model.JXC.TB_SupplierAdvancePayment model, SqlCommand objCommand)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TB_SupplierAdvancePayment set ");
            if (model.ProNo != null)
            {
                strSql.Append("ProNo='" + model.ProNo + "',");
            }
            if (model.CreateName != null)
            {
                strSql.Append("CreateName='" + model.CreateName + "',");
            }
            if (model.CreteTime != null)
            {
                strSql.Append("CreteTime='" + model.CreteTime + "',");
            }
            if (model.Status != null)
            {
                strSql.Append("Status='" + model.Status + "',");
            }
            if (model.SumActPay != null)
            {
                strSql.Append("SumActPay='" + model.SumActPay + "',");
            }
            strSql.Append("FristFPNo='" + model.FristFPNo + "',");
            strSql.Append("SecondFPNo='" + model.SecondFPNo + "',");
            strSql.Append("LastFPNo='" + (model.SecondFPNo != "" ? model.SecondFPNo : model.FristFPNo) + "',");
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where Id=" + model.Id + "");
            objCommand.CommandText = strSql.ToString();
            objCommand.ExecuteNonQuery();
        }
Exemplo n.º 2
0
        public bool updateTran(VAN_OA.Model.JXC.TB_SupplierAdvancePayment model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <SupplierToInvoiceView> orders, string IDS)
        {
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;
                try
                {
                    objCommand.Parameters.Clear();
                    model.Status = eform.state;
                    Update(model, objCommand);
                    tb_EFormService eformSer = new tb_EFormService();
                    eformSer.Update(eform, objCommand);
                    tb_EFormsService eformsSer = new tb_EFormsService();
                    eformsSer.Add(forms, objCommand);

                    TB_SupplierAdvancePaymentsService OrdersSer = new TB_SupplierAdvancePaymentsService();
                    for (int i = 0; i < orders.Count; i++)
                    {
                        if (orders[i].IfCheck == false)
                        {
                            continue;
                        }
                        var modelSupplierInvoices = new TB_SupplierAdvancePayments();
                        modelSupplierInvoices.Ids                  = orders[i].payIds;
                        modelSupplierInvoices.Id                   = model.Id;
                        modelSupplierInvoices.CaiIds               = orders[i].Ids;
                        modelSupplierInvoices.SupplierFPNo         = orders[i].SupplierFPNo;
                        modelSupplierInvoices.SupplierInvoiceDate  = orders[i].SupplierInvoiceDate.Value;
                        modelSupplierInvoices.SupplierInvoiceNum   = orders[i].SupplierInvoiceNum;
                        modelSupplierInvoices.SupplierInvoicePrice = orders[i].SupplierInvoicePrice;
                        modelSupplierInvoices.SupplierInvoiceTotal = orders[i].SupplierInvoiceTotal;
                        if (eform.state == "通过" && (orders[i].SupplierProNo == null || orders[i].SupplierProNo == ""))
                        {
                            modelSupplierInvoices.SupplierProNo = GetAllE_No("TB_SupplierAdvancePayments", objCommand);
                        }
                        OrdersSer.Update(modelSupplierInvoices, objCommand);
                    }

                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public VAN_OA.Model.JXC.TB_SupplierAdvancePayment ReaderBind(IDataReader dataReader)
        {
            VAN_OA.Model.JXC.TB_SupplierAdvancePayment model = new VAN_OA.Model.JXC.TB_SupplierAdvancePayment();
            object ojb;

            ojb = dataReader["Id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Id = (int)ojb;
            }
            model.ProNo      = dataReader["ProNo"].ToString();
            model.CreateName = dataReader["CreateName"].ToString();
            model.CreteTime  = Convert.ToDateTime(dataReader["CreteTime"]);
            model.Status     = dataReader["Status"].ToString();
            model.Remark     = dataReader["Remark"].ToString();
            model.FristFPNo  = dataReader["FristFPNo"].ToString();
            model.SecondFPNo = dataReader["SecondFPNo"].ToString();
            return(model);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VAN_OA.Model.JXC.TB_SupplierAdvancePayment GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   ");
            strSql.Append(" Id,ProNo,CreateName,CreteTime,Status,Remark,FristFPNo,SecondFPNo ");
            strSql.Append(" from TB_SupplierAdvancePayment ");
            strSql.Append(" where Id=" + id + "");
            VAN_OA.Model.JXC.TB_SupplierAdvancePayment model = null;
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    if (dataReader.Read())
                    {
                        model = ReaderBind(dataReader);
                    }
                }
            }
            return(model);
        }
Exemplo n.º 5
0
        public int addTran(VAN_OA.Model.JXC.TB_SupplierAdvancePayment model, VAN_OA.Model.EFrom.tb_EForm eform, List <SupplierToInvoiceView> orders, out int MainId)
        {
            int id = 0;

            MainId = 0;
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;
                TB_SupplierAdvancePaymentsService OrdersSer = new TB_SupplierAdvancePaymentsService();
                try
                {
                    objCommand.Parameters.Clear();
                    tb_EFormService eformSer = new tb_EFormService();
                    string          proNo    = eformSer.GetAllE_No1("TB_SupplierAdvancePayment", objCommand);
                    model.ProNo   = proNo;
                    eform.E_No    = proNo;
                    model.Status  = eform.state;
                    id            = Add(model, objCommand);
                    MainId        = id;
                    eform.allE_id = id;
                    eformSer.Add(eform, objCommand);

                    for (int i = 0; i < orders.Count; i++)
                    {
                        if (orders[i].IfCheck == false)
                        {
                            continue;
                        }
                        var modelSupplierInvoices = new TB_SupplierAdvancePayments();
                        modelSupplierInvoices.Id                   = id;
                        modelSupplierInvoices.CaiIds               = orders[i].Ids;
                        modelSupplierInvoices.SupplierFPNo         = orders[i].SupplierFPNo;
                        modelSupplierInvoices.SupplierInvoiceDate  = orders[i].SupplierInvoiceDate.Value;
                        modelSupplierInvoices.SupplierInvoiceNum   = orders[i].SupplierInvoiceNum;
                        modelSupplierInvoices.SupplierInvoicePrice = orders[i].SupplierInvoicePrice;
                        modelSupplierInvoices.SupplierInvoiceTotal = orders[i].SupplierInvoiceTotal;
                        if (eform.state == "通过" && (orders[i].SupplierProNo == null || orders[i].SupplierProNo == ""))
                        {
                            modelSupplierInvoices.SupplierProNo = GetAllE_No("TB_SupplierAdvancePayments", objCommand);
                        }
                        OrdersSer.Add(modelSupplierInvoices, objCommand);
                    }
                    var otherOrders = orders.FindAll(t => t.IfCheck == false);
                    foreach (var otherOrder in otherOrders)
                    {
                        string insertSql = string.Format("insert into TB_TempSupplierInvoice values(0,{1},{0})", id, otherOrder.payIds);
                        objCommand.CommandText = insertSql;
                        objCommand.ExecuteNonQuery();
                    }
                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(0);
                }
                return(id);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VAN_OA.Model.JXC.TB_SupplierAdvancePayment model, SqlCommand objCommand)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.ProNo != null)
            {
                strSql1.Append("ProNo,");
                strSql2.Append("'" + model.ProNo + "',");
            }
            if (model.CreateName != null)
            {
                strSql1.Append("CreateName,");
                strSql2.Append("'" + model.CreateName + "',");
            }
            if (model.CreteTime != null)
            {
                strSql1.Append("CreteTime,");
                strSql2.Append("'" + model.CreteTime + "',");
            }
            if (model.Status != null)
            {
                strSql1.Append("Status,");
                strSql2.Append("'" + model.Status + "',");
            }
            if (model.Remark != null)
            {
                strSql1.Append("Remark,");
                strSql2.Append("'" + model.Remark + "',");
            }
            if (model.SumActPay != null)
            {
                strSql1.Append("SumActPay,");
                strSql2.Append("" + model.SumActPay + ",");
            }
            strSql1.Append("FristFPNo,");
            strSql2.Append("'" + model.FristFPNo + "',");

            strSql1.Append("SecondFPNo,");
            strSql2.Append("'" + model.SecondFPNo + "',");

            strSql.Append("insert into TB_SupplierAdvancePayment(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");

            int result;

            objCommand.CommandText = strSql.ToString();
            object obj = objCommand.ExecuteScalar();

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }