예제 #1
0
        public List <Sell_OrderFPBack> GetFPtoInvoiceView(string where)
        {
            string strSql = @"SELECT GuestNAME,[Id],[FPBackTime],[ProNo],[PONo],[POName],[FPNo],[FPNoStyle],[Total],[sumTotal],[chaTotals]   FROM [Fp_ToInvoice] where " + where;
            List <VAN_OA.Model.JXC.Sell_OrderFPBack> list = new List <VAN_OA.Model.JXC.Sell_OrderFPBack>();

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        VAN_OA.Model.JXC.Sell_OrderFPBack model = new VAN_OA.Model.JXC.Sell_OrderFPBack();
                        object ojb;
                        ojb = dataReader["Id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Id = (int)ojb;
                        }

                        ojb = dataReader["FPBackTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.FPBackTime = Convert.ToDateTime(ojb);
                        }
                        model.ProNo  = dataReader["ProNo"].ToString();
                        model.PONo   = dataReader["PONo"].ToString();
                        model.POName = dataReader["POName"].ToString();
                        ojb          = dataReader["FPNo"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.FPNo = ojb.ToString();
                        }

                        ojb = dataReader["sumTotal"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.sumTotal = Convert.ToDecimal(ojb);
                        }
                        ojb = dataReader["chaTotals"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.chaTotals = Convert.ToDecimal(ojb);
                        }

                        ojb = dataReader["FPNo"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.FPNo = ojb.ToString();
                        }
                        model.GuestName = dataReader["GuestNAME"].ToString();

                        list.Add(model);
                    }
                }
            }
            return(list);
        }
예제 #2
0
        public int addTran(VAN_OA.Model.JXC.Sell_OrderFPBack model, VAN_OA.Model.EFrom.tb_EForm eform, List <Sell_OrderFPBacks> 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;
                Sell_OrderFPBacksService OrdersSer = new Sell_OrderFPBacksService();


                try
                {
                    objCommand.Parameters.Clear();
                    tb_EFormService eformSer = new tb_EFormService();
                    string          proNo    = eformSer.GetAllE_No("Sell_OrderFPBack", objCommand);
                    model.ProNo = proNo;
                    eform.E_No  = proNo;

                    decimal total = 0;
                    foreach (var m in orders)
                    {
                        total += m.GoodSellPriceTotal;
                    }
                    model.Total  = total;
                    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++)
                    {
                        orders[i].id = id;
                        OrdersSer.Add(orders[i], objCommand);
                    }
                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(0);
                }
                return(id);
            }
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(VAN_OA.Model.JXC.Sell_OrderFPBack model, SqlCommand objCommand)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Sell_OrderFPBack set ");

            if (model.Remark != null)
            {
                strSql.Append("Remark='" + model.Remark + "',");
            }
            else
            {
                strSql.Append("Remark= null ,");
            }
            if (model.Status != null)
            {
                strSql.Append("Status='" + model.Status + "',");
            }
            if (model.FPNo != null)
            {
                strSql.Append("FPNo='" + model.FPNo + "',");
            }
            else
            {
                strSql.Append("FPNo= null ,");
            }

            if (model.FPBackType != null)
            {
                strSql.Append("FPBackType=" + model.FPBackType + ",");
            }
            else
            {
                strSql.Append("FPBackType= null ,");
            }

            strSql.Append("FPBackTime='" + model.FPBackTime + "',");

            strSql.Append("Total=" + model.Total + ",");


            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where Id=" + model.Id + "");
            objCommand.CommandText = strSql.ToString();
            objCommand.ExecuteNonQuery();
        }
예제 #4
0
        public bool updateTran(VAN_OA.Model.JXC.Sell_OrderFPBack model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <Sell_OrderFPBacks> orders, string IDS)
        {
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;
                try
                {
                    decimal total = 0;
                    foreach (var m in orders)
                    {
                        total += m.GoodSellPriceTotal;
                    }
                    model.Total = total;
                    System.Collections.Hashtable hs = new System.Collections.Hashtable();
                    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);
                    //====删除所有子单据
                    string delete = "delete from Sell_OrderFPBacks where id=" + model.Id;
                    objCommand.CommandText = delete;
                    objCommand.ExecuteNonQuery();
                    //====

                    Sell_OrderFPBacksService OrdersSer = new Sell_OrderFPBacksService();
                    for (int i = 0; i < orders.Count; i++)
                    {
                        orders[i].id = model.Id;
                        OrdersSer.Add(orders[i], objCommand);
                    }
                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(false);
                }
            }

            return(true);
        }
예제 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VAN_OA.Model.JXC.Sell_OrderFPBack GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   ");
            strSql.Append(" PId,Sell_OrderFPBack.Id,CreateUserId,CreateTime,FPBackTime,GuestNAME,FPBackType,ProNo,PONo,POName,Remark ,tb_User.loginName as CreateName,Status,FPNo,Total ");
            strSql.Append(" from Sell_OrderFPBack left join tb_User on tb_User.id=CreateUserId ");
            strSql.Append(" where Sell_OrderFPBack.Id=" + id + "");

            VAN_OA.Model.JXC.Sell_OrderFPBack 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);
        }
예제 #6
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public VAN_OA.Model.JXC.Sell_OrderFPBack ReaderBind(IDataReader dataReader)
        {
            VAN_OA.Model.JXC.Sell_OrderFPBack model = new VAN_OA.Model.JXC.Sell_OrderFPBack();
            object ojb;

            ojb = dataReader["Id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Id = (int)ojb;
            }
            ojb = dataReader["CreateUserId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateUserId = (int)ojb;
            }
            ojb = dataReader["CreateTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateTime = (DateTime)ojb;
            }
            ojb = dataReader["FPBackTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FPBackTime = (DateTime)ojb;
            }
            model.GuestName  = dataReader["GuestNAME"].ToString();
            model.FPBackType = Convert.ToInt32(dataReader["FPBackType"]);


            model.ProNo  = dataReader["ProNo"].ToString();
            model.PONo   = dataReader["PONo"].ToString();
            model.POName = dataReader["POName"].ToString();
            ojb          = dataReader["Remark"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Remark = dataReader["Remark"].ToString();
            }

            ojb = dataReader["CreateName"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateName = ojb.ToString();
            }

            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = ojb.ToString();
            }
            ojb = dataReader["FPNo"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FPNo = ojb.ToString();
            }
            ojb = dataReader["Total"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Total = Convert.ToDecimal(ojb);
            }

            ojb = dataReader["PId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.PId = Convert.ToInt32(ojb);
            }
            return(model);
        }
예제 #7
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VAN_OA.Model.JXC.Sell_OrderFPBack model, SqlCommand objCommand)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.CreateUserId != null)
            {
                strSql1.Append("CreateUserId,");
                strSql2.Append("" + model.CreateUserId + ",");
            }

            strSql1.Append("CreateTime,");
            strSql2.Append("getdate(),");

            if (model.FPBackTime != null)
            {
                strSql1.Append("FPBackTime,");
                strSql2.Append("'" + model.FPBackTime + "',");
            }
            if (model.GuestName != null)
            {
                strSql1.Append("GuestNAME,");
                strSql2.Append("'" + model.GuestName + "',");
            }
            if (model.FPBackType != null)
            {
                strSql1.Append("FPBackType,");
                strSql2.Append("" + model.FPBackType + ",");
            }


            if (model.ProNo != null)
            {
                strSql1.Append("ProNo,");
                strSql2.Append("'" + model.ProNo + "',");
            }
            if (model.PONo != null)
            {
                strSql1.Append("PONo,");
                strSql2.Append("'" + model.PONo + "',");
            }
            if (model.POName != null)
            {
                strSql1.Append("POName,");
                strSql2.Append("'" + model.POName + "',");
            }
            if (model.Remark != null)
            {
                strSql1.Append("Remark,");
                strSql2.Append("'" + model.Remark + "',");
            }
            if (model.Status != null)
            {
                strSql1.Append("Status,");
                strSql2.Append("'" + model.Status + "',");
            }
            if (model.FPNo != null)
            {
                strSql1.Append("FPNo,");
                strSql2.Append("'" + model.FPNo + "',");
            }

            strSql1.Append("Total,");
            strSql2.Append("" + model.Total + ",");

            strSql1.Append("PId,");
            strSql2.Append("" + model.PId + ",");

            strSql.Append("insert into Sell_OrderFPBack(");
            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);
        }