コード例 #1
0
        /// <summary>
        /// 获得所有为入库的信息
        /// </summary>
        public List <VAN_OA.Model.JXC.CAI_OrderInHouse> GetListArrayCai_POOrderInHouse_Cai_POOrderOutHouse_View(string strWhere)
        {
            //            alter view [dbo].[Cai_POOrderInHouse_Cai_POOrderOutHouse_View]
            //as


            //SELECT CAI_OrderInHouse.Id,CreateUserId,CreateTime,RuTime,Supplier,DoPer,HouseID,ChcekProNo,ProNo,PONo,POName,Remark ,tb_User.loginName as CreateName
            //  FROM [VANBAND].[dbo].[CAI_OrderInHouse]
            //  left join tb_User on tb_User.id=CreateUserId
            //  where CAI_OrderInHouse.Id in (
            //select id from CAI_OrderInHouses
            //left join
            //(
            //select  OrderCheckIds,SUM(GoodNum) as totalOrderNum from CAI_OrderOutHouses
            //where OrderCheckIds<>0  and  id in (select allE_id from tb_EForm where proId in (
            //select pro_Id from A_ProInfo where pro_Type='采购退货') and state<>'不通过')
            //group by OrderCheckIds
            //)
            //as newtable on CAI_OrderInHouses.Ids=newtable.OrderCheckIds where (CAI_OrderInHouses.GoodNum>newtable.totalOrderNum or totalOrderNum is null)
            //and CAI_OrderInHouses.id in (select allE_id from tb_EForm where proId in (
            //select pro_Id from A_ProInfo where pro_Type='采购入库') and state='通过')
            //)

            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   ");
            strSql.Append("HouseName, Id,CreateUserId,CreateTime,RuTime,Supplier,DoPer,HouseID,ChcekProNo,ProNo,PONo,POName,Remark , CreateName,Status,FPNo,DaiLi ,GuestName");
            strSql.Append(" from Cai_POOrderInHouse_Cai_POOrderOutHouse_View");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by ProNo desc ");
            List <VAN_OA.Model.JXC.CAI_OrderInHouse> list = new List <VAN_OA.Model.JXC.CAI_OrderInHouse>();

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        CAI_OrderInHouse model = new CAI_OrderInHouse();
                        model = ReaderBind(dataReader);
                        object ojb;
                        ojb = dataReader["HouseName"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.HouseName = ojb.ToString();
                        }
                        list.Add(model);
                    }
                }
            }
            return(list);
        }
コード例 #2
0
        protected void gvList_RowEditing(object sender, GridViewEditEventArgs e)
        {
            CAI_OrderInHouse model = new CAI_OrderInHouse();
            Label            Id    = gvList.Rows[e.NewEditIndex].FindControl("Id") as Label;

            if (Id != null)
            {
                model.Id = Convert.ToInt32(Id.Text);
            }

            Label HouseID = gvList.Rows[e.NewEditIndex].FindControl("HouseID") as Label;

            if (HouseID != null)
            {
                model.HouseID = Convert.ToInt32(HouseID.Text);
            }

            Label lblPOName = gvList.Rows[e.NewEditIndex].FindControl("POName") as Label;

            if (lblPOName != null)
            {
                model.POName = lblPOName.Text;
            }

            Label PONo = gvList.Rows[e.NewEditIndex].FindControl("PONo") as Label;

            if (PONo != null)
            {
                model.PONo = PONo.Text;
            }


            Label Supplier = gvList.Rows[e.NewEditIndex].FindControl("Supplier") as Label;

            if (Supplier != null)
            {
                model.Supplier = Supplier.Text;
            }

            Label ProNo = gvList.Rows[e.NewEditIndex].FindControl("ProNo") as Label;

            if (ProNo != null)
            {
                model.ProNo = ProNo.Text;
            }

            Label DoPer = gvList.Rows[e.NewEditIndex].FindControl("DoPer") as Label;

            if (ProNo != null)
            {
                model.DoPer = DoPer.Text;
            }
            Session["DioPOOrderInHouse"] = model;
            Response.Write("<script>window.close();window.opener=null;</script>");
        }
コード例 #3
0
        protected void gvMain_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#EAF1FD',this.style.fontWeight='';");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");

                CAI_OrderInHouse model = e.Row.DataItem as CAI_OrderInHouse;
                if (model.Count2 != model.Count1)
                {
                    e.Row.BackColor = System.Drawing.Color.LightGray;
                }
            }
        }
コード例 #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FormCheck())
            {
                btnSub.Enabled = false;
                if (base.Request["ProId"] != null)
                {
                    #region 获取单据基本信息

                    CAI_OrderInHouse order = new CAI_OrderInHouse();

                    int CreatePer = Convert.ToInt32(DBHelp.ExeScalar(string.Format("select ID from tb_User where loginName='{0}'", txtName.Text)));
                    order.CreateUserId = CreatePer;
                    order.ChcekProNo   = txtChcekProNo.Text;
                    order.DoPer        = txtCaiGou.Text;
                    order.HouseID      = Convert.ToInt32(ddlHouse.SelectedValue);
                    order.POName       = txtPOName.Text;
                    order.PONo         = txtPONo.Text;
                    order.RuTime       = Convert.ToDateTime(txtRuTime.Text);
                    order.Remark       = txtRemark.Text;
                    order.Supplier     = txtSupplier.Text;
                    order.FPNo         = txtFPNo.Text;
                    order.DaiLi        = "";

                    order.GuestName = lblGuestName.Text;
                    List <CAI_OrderInHouses> POOrders = Session["Orders"] as List <CAI_OrderInHouses>;

                    #endregion
                    if (Request["allE_id"] == null)//单据增加+//再次编辑)
                    {
                        VAN_OA.Model.EFrom.tb_EForm eform = new tb_EForm();

                        int userId = CreatePer;
                        eform.appPer     = userId;
                        eform.appTime    = DateTime.Now;
                        eform.createPer  = Convert.ToInt32(Session["currentUserId"].ToString());
                        eform.createTime = DateTime.Now;
                        eform.proId      = Convert.ToInt32(Request["ProId"]);

                        if (ddlPers.Visible == false)
                        {
                            eform.state    = "通过";
                            eform.toPer    = 0;
                            eform.toProsId = 0;
                        }
                        else
                        {
                            eform.state    = "执行中";
                            eform.toPer    = Convert.ToInt32(ddlPers.SelectedItem.Value);
                            eform.toProsId = Convert.ToInt32(ViewState["ids"]);
                        }


                        int MainId = 0;


                        CAI_OrderInHouseService POOrderSer = new CAI_OrderInHouseService();
                        if (POOrderSer.addTran(order, eform, POOrders, out MainId) > 0)
                        {
                            //new TB_SupplierInvoiceService().SetRuKuPayStatus(POOrders);
                            base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交成功!');</script>");

                            if (Session["backurl"] != null)
                            {
                                base.Response.Redirect("~" + Session["backurl"]);
                            }
                            else
                            {
                                base.Response.Redirect("~/EFrom/MyRequestEForms.aspx");
                            }
                        }
                        else
                        {
                            btnSub.Enabled = false;
                            base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交失败!');</script>");
                        }
                    }
                    else//审核
                    {
                        #region 本单据的ID
                        order.Id = Convert.ToInt32(Request["allE_id"]);
                        #endregion
                        tb_EForm  eform = new tb_EForm();
                        tb_EForms forms = new tb_EForms();


                        eform.id      = Convert.ToInt32(Request["EForm_Id"]);
                        eform.proId   = Convert.ToInt32(Request["ProId"]);
                        eform.allE_id = Convert.ToInt32(Request["allE_id"]);
                        int userId = CreatePer;
                        eform.appPer = userId;



                        tb_EFormService fromSer = new tb_EFormService();
                        if (ViewState["ifConsignor"] != null && Convert.ToBoolean(ViewState["ifConsignor"]) == true)
                        {
                            forms.audPer    = fromSer.getCurrentAuPer(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]));
                            forms.consignor = Convert.ToInt32(Session["currentUserId"]);
                        }
                        else
                        {
                            forms.audPer    = Convert.ToInt32(Session["currentUserId"]);
                            forms.consignor = 0;
                        }
                        if (fromSer.ifAudiPerAndCon(Convert.ToInt32(Session["currentUserId"]), Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])) == false)
                        {
                            if (Session["backurl"] != null)
                            {
                                base.Response.Redirect("~" + Session["backurl"]);
                            }
                            else
                            {
                                base.Response.Redirect("~/EFrom/MyRequestEForms.aspx");
                            }
                            return;
                        }
                        forms.doTime      = DateTime.Now;
                        forms.e_Id        = Convert.ToInt32(Request["EForm_Id"]); //fromSer.getCurrentid(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]));
                        forms.idea        = txtResultRemark.Text;
                        forms.prosIds     = fromSer.getCurrenttoProsId(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]));
                        forms.resultState = ddlResult.Text;
                        forms.RoleName    = fromSer.getCurrenttoRoleName(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]));
                        if (ddlPers.Visible == false)//说明为最后一次审核
                        {
                            eform.state    = ddlResult.Text;
                            eform.toPer    = 0;
                            eform.toProsId = 0;
                        }
                        else
                        {
                            if (ddlResult.Text == "不通过")
                            {
                                eform.state    = ddlResult.Text;
                                eform.toPer    = 0;
                                eform.toProsId = 0;
                            }
                            else
                            {
                                eform.state    = "执行中";
                                eform.toPer    = Convert.ToInt32(ddlPers.SelectedItem.Value);
                                eform.toProsId = Convert.ToInt32(ViewState["ids"]);
                            }
                        }
                        CAI_OrderInHouseService POOrderSer = new CAI_OrderInHouseService();
                        string IDS = ViewState["POOrdersIds"].ToString();


                        if (POOrderSer.updateTran(order, eform, forms, POOrders, IDS))
                        {
                            base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交成功!');</script>");
                            if (ddlPers.Visible == false)
                            {
                                //new TB_SupplierInvoiceService().SetRuKuPayStatus(POOrders);
                            }
                            if (Session["backurl"] != null)
                            {
                                base.Response.Redirect("~" + Session["backurl"]);
                            }
                            else
                            {
                                base.Response.Redirect("~/EFrom/MyRequestEForms.aspx");
                            }
                        }
                        else
                        {
                            btnSub.Enabled = false;
                            base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('提交失败!');</script>");
                        }
                    }
                }
            }
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                //请假单子
                Session["Orders"]    = null;
                lbtnAddFiles.Visible = false;

                gvList.Columns[0].Visible  = false;
                gvList.Columns[6].Visible  = false;
                gvList.Columns[10].Visible = false;


                Dal.BaseInfo.TB_HouseInfoService   houseSer  = new VAN_OA.Dal.BaseInfo.TB_HouseInfoService();
                List <Model.BaseInfo.TB_HouseInfo> houseList = houseSer.GetListArray("");
                ddlHouse.DataSource = houseList;
                ddlHouse.DataBind();
                ddlHouse.DataTextField  = "houseName";
                ddlHouse.DataValueField = "id";


                if (base.Request["ProId"] != null)
                {
                    //加载基本数据
                    VAN_OA.Model.User use = Session["userInfo"] as VAN_OA.Model.User;
                    txtName.Text = use.LoginName;



                    tb_EFormService eformSer = new tb_EFormService();
                    if (Request["allE_id"] == null)//单据增加
                    {
                        txtRuTime.Text = DateTime.Now.ToString();
                        //权限1(销售)
                        lbtnAddFiles.Visible       = true;
                        gvList.Columns[0].Visible  = true;
                        gvList.Columns[6].Visible  = true;
                        gvList.Columns[7].Visible  = false;
                        gvList.Columns[10].Visible = true;
                        gvList.Columns[11].Visible = false;

                        //加载初始数据

                        List <CAI_OrderInHouses> orders = new List <CAI_OrderInHouses>();
                        Session["Orders"]        = orders;
                        ViewState["OrdersCount"] = orders.Count;

                        gvList.DataSource = orders;
                        gvList.DataBind();

                        txtRuTime.Text = DateTime.Now.ToString();



                        //检查自己是否在请假单中流程设置中,来确定自己下一个审批人

                        lblResult.Visible       = false;
                        lblYiJian.Visible       = false;
                        ddlResult.Visible       = false;
                        txtResultRemark.Visible = false;


                        if (eformSer.ifHasNodes(Convert.ToInt32(Request["ProId"])))
                        {
                            //获取审批人
                            int pro_IDs = 0;
                            int ids     = 0;
                            List <A_Role_User> roleUserList = eformSer.getFristNodeUsers(Convert.ToInt32(Session["currentUserId"].ToString()), Convert.ToInt32(Request["ProId"]), out ids);

                            ViewState["ids"] = ids;
                            if (roleUserList != null)
                            {
                                ddlPers.DataSource = roleUserList;
                                ddlPers.DataBind();
                                ddlPers.DataTextField  = "UserName";
                                ddlPers.DataValueField = "UserId";
                            }
                            else
                            {
                                lblPer.Visible  = false;
                                ddlPers.Visible = false;
                            }
                        }
                        else
                        {
                            lblPer.Visible  = false;
                            ddlPers.Visible = false;
                        }
                    }

                    else//单据审批
                    {
                        ViewState["POOrdersIds"] = "";


                        //加载已经审批的数据
                        tb_EFormsService eformsSer = new tb_EFormsService();
                        List <VAN_OA.Model.EFrom.tb_EForms> eforms = eformsSer.GetListArray(string.Format(" e_Id in (select id from tb_EForm where proId={0} and allE_id={1})",
                                                                                                          Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])));
                        if (eforms.Count > 0)
                        {
                            string mess = @"<table cellpadding='0' cellspacing='0' width='100%' bordercolorlight='#999999' bordercolordark='#FFFFFF' border='1' ><tr><td colspan='6' style=' height:20px; background-color:#336699; color:White;'>流程图</td></tr>";


                            for (int i = 0; i < eforms.Count; i++)
                            {
                                string per = "";
                                if (eforms[i].consignor != null && eforms[i].consignor != 0)
                                {
                                    per = eforms[i].Consignor_Name + "(委托人:" + eforms[i].Audper_Name + ")";
                                }
                                else
                                {
                                    per = eforms[i].Audper_Name;
                                }
                                mess += string.Format("<tr><td align='center'>第{0}步</td><td>序号{0}:{1}</td><td><span style='color:red;'>{2}</span>[<span style='color:blue;'>{3} {4}</span>]<br/>意见:{5}</td></tr>",
                                                      i + 1, eforms[i].RoleName
                                                      , per, eforms[i].resultState, eforms[i].doTime, eforms[i].idea);
                            }
                            mess        += "</table>";
                            lblMess.Text = mess;
                        }

                        ViewState["EformsCount"] = eforms.Count;



                        #region  加载 请假单数据

                        CAI_OrderInHouseService mainSer = new CAI_OrderInHouseService();
                        CAI_OrderInHouse        pp      = mainSer.GetModel(Convert.ToInt32(Request["allE_id"]));
                        txtName.Text = pp.CreateName;

                        txtChcekProNo.Text = pp.ChcekProNo;

                        txtPOName.Text   = pp.POName;
                        txtPONo.Text     = pp.PONo;
                        txtRemark.Text   = pp.Remark;
                        txtRuTime.Text   = pp.RuTime.ToString();
                        txtSupplier.Text = pp.Supplier;

                        ddlHouse.Text  = pp.HouseID.ToString();
                        txtCaiGou.Text = pp.DoPer;

                        txtFPNo.Text = pp.FPNo;
                        if (pp.ProNo != null)
                        {
                            lblProNo.Text = pp.ProNo;
                        }
                        CAI_OrderInHousesService ordersSer = new CAI_OrderInHousesService();
                        List <CAI_OrderInHouses> orders    = ordersSer.GetListArray(" 1=1 and CAI_OrderInHouses.id=" + Request["allE_id"]);
                        Session["Orders"]        = orders;
                        ViewState["OrdersCount"] = orders.Count;

                        gvList.DataSource = orders;
                        gvList.DataBind();

                        #endregion
                        //判断单据是否已经结束
                        if (eformSer.ifFinish(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])))
                        {
                            btnSub.Visible          = false;
                            lblPer.Visible          = false;
                            ddlPers.Visible         = false;
                            lblResult.Visible       = false;
                            lblYiJian.Visible       = false;
                            ddlResult.Visible       = false;
                            txtResultRemark.Visible = false;

                            setEnable(false);
                        }
                        else
                        {
                            //是否为审核人
                            if (eformSer.ifAudiPer(Convert.ToInt32(Session["currentUserId"]), Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])))
                            {
                                if (eformSer.ifLastNode(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])))
                                {
                                    lblPer.Visible  = false;
                                    ddlPers.Visible = false;
                                }
                                else
                                {
                                    int ids = 0;

                                    List <A_Role_User> roleUserList = eformSer.getUserToAdu(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]), out ids);

                                    ViewState["ids"] = ids;
                                    if (roleUserList != null)
                                    {
                                        ddlPers.DataSource = roleUserList;
                                        ddlPers.DataBind();
                                        ddlPers.DataTextField  = "UserName";
                                        ddlPers.DataValueField = "UserId";
                                    }
                                }
                                setEnable(eformSer.ifEdit(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])));
                            }
                            else
                            {
                                //是否为代理人
                                if (eformSer.ifAudiPerByUserName(Convert.ToInt32(Session["currentUserId"]), Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])))
                                {
                                    ViewState["ifConsignor"] = true;
                                    if (eformSer.ifLastNode(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])))
                                    {
                                        lblPer.Visible  = false;
                                        ddlPers.Visible = false;
                                    }
                                    else
                                    {
                                        int ids = 0;
                                        List <A_Role_User> roleUserList = eformSer.getUserToAdu(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"]), out ids);
                                        ViewState["ids"] = ids;
                                        if (roleUserList != null)
                                        {
                                            ddlPers.DataSource = roleUserList;
                                            ddlPers.DataBind();
                                            ddlPers.DataTextField  = "UserName";
                                            ddlPers.DataValueField = "UserId";
                                        }
                                    } setEnable(eformSer.ifEdit(Convert.ToInt32(Request["ProId"]), Convert.ToInt32(Request["allE_id"])));
                                }
                                else
                                {
                                    btnSub.Visible  = false;
                                    lblPer.Visible  = false;
                                    ddlPers.Visible = false;

                                    lblResult.Visible       = false;
                                    lblYiJian.Visible       = false;
                                    ddlResult.Visible       = false;
                                    txtResultRemark.Visible = false;
                                    setEnable(false);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        public bool updateTran(VAN_OA.Model.JXC.CAI_OrderCheck model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <CAI_OrderChecks> orders, string IDS)
        {
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;

                CG_POOrdersService OrdersSer = new CG_POOrdersService();
                CG_POCaiService    CaiSer    = new CG_POCaiService();
                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);

                    CAI_OrderChecksService myOrderChecks = new CAI_OrderChecksService();
                    for (int i = 0; i < orders.Count; i++)
                    {
                        // orders[i].CheckId = model.Id;
                        //if (orders[i].IfUpdate == true && orders[i].Ids != 0)
                        //{

                        myOrderChecks.Update(orders[i], objCommand);

                        //}
                        //else if (orders[i].Ids == 0)
                        //{
                        //    OrdersSer.Add(orders[i], objCommand);

                        //}
                    }

                    //入库
                    if (eform.state == "通过")
                    {
                        tb_EForm eformMain = new tb_EForm();
                        int      proId     = 0;
                        string   sql       = "select Pro_Id from A_ProInfo where pro_Type='采购入库'";
                        objCommand.CommandText = sql;

                        proId = Convert.ToInt32(objCommand.ExecuteScalar());

                        eformMain.appPer     = eform.appPer;
                        eformMain.appTime    = DateTime.Now;
                        eformMain.createPer  = eform.appPer;
                        eformMain.createTime = DateTime.Now;
                        eformMain.proId      = proId;
                        eformMain.state      = "通过";
                        eformMain.toPer      = 0;
                        eformMain.toProsId   = 0;

                        CAI_OrderInHouseService orderInHouse = new CAI_OrderInHouseService();
                        sql = "select top 1 id from TB_HouseInfo where ifdefault=1 ";
                        objCommand.CommandText = sql;
                        int objhouseId = Convert.ToInt32(objCommand.ExecuteScalar());
                        CAI_OrderInHouse orderInModel = new CAI_OrderInHouse()
                        {
                            ChcekProNo   = model.ProNo,
                            CreateTime   = DateTime.Now,
                            CreateUserId = eform.appPer,
                            GuestName    = orders[0].GuestName,
                            HouseID      = objhouseId,
                            POName       = orders[0].POName,
                            PONo         = orders[0].PONo,
                            RuTime       = DateTime.Now,
                            Status       = "通过",
                            Supplier     = orders[0].SupplierName,
                            DoPer        = orders[0].CaiGouPer,
                            DaiLi        = orders[0].CaiGouPer,
                            FPNo         = "",
                            Remark       = ""
                        };
                        List <CAI_OrderInHouses> ordersInHouses = new List <CAI_OrderInHouses>();
                        foreach (var m in orders)
                        {
                            CAI_OrderInHouses orderM = new CAI_OrderInHouses()
                            {
                                GooId            = m.CheckGoodId,
                                GoodNum          = m.CheckNum,
                                GoodPrice        = m.CheckPrice,
                                OrderCheckIds    = m.Ids,
                                QingGouPer       = m.QingGou,
                                CaiLastTruePrice = m.CheckLastTruePrice
                            };
                            ordersInHouses.Add(orderM);
                        }

                        orderInHouse.addTran(orderInModel, eformMain, ordersInHouses, objCommand);
                    }
                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(false);
                }
            }

            return(true);
        }
コード例 #7
0
        public int addTran(VAN_OA.Model.JXC.CAI_OrderCheck model, VAN_OA.Model.EFrom.tb_EForm eform, List <CAI_OrderChecks> orders, out int MainId, List <string> ids = null)
        {
            int id = 0;

            MainId = 0;
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;
                CAI_OrderChecksService OrdersSer = new CAI_OrderChecksService();


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

                    model.Status = eform.state;
                    id           = Add(model, objCommand);
                    model.Id     = id;
                    MainId       = id;

                    eform.allE_id = id;
                    eformSer.Add(eform, objCommand);
                    for (int i = 0; i < orders.Count; i++)
                    {
                        orders[i].CheckId = id;
                        orders[i].Ids     = OrdersSer.Add(orders[i], objCommand);
                    }

                    //入库
                    if (eform.state == "通过")
                    {
                        tb_EForm eformMain = new tb_EForm();
                        int      proId     = 0;
                        string   sql       = "select Pro_Id from A_ProInfo where pro_Type='采购入库'";
                        objCommand.CommandText = sql;

                        proId = Convert.ToInt32(objCommand.ExecuteScalar());

                        eformMain.appPer     = eform.appPer;
                        eformMain.appTime    = DateTime.Now.AddSeconds(1);
                        eformMain.createPer  = eform.appPer;
                        eformMain.createTime = DateTime.Now.AddSeconds(1);
                        eformMain.proId      = proId;
                        eformMain.state      = "通过";
                        eformMain.toPer      = 0;
                        eformMain.toProsId   = 0;
                        eform.E_LastTime     = DateTime.Now.AddSeconds(1);
                        CAI_OrderInHouseService orderInHouse = new CAI_OrderInHouseService();
                        sql = "select top 1 id from TB_HouseInfo where ifdefault=1 ";
                        objCommand.CommandText = sql;
                        int objhouseId = Convert.ToInt32(objCommand.ExecuteScalar());
                        CAI_OrderInHouse orderInModel = new CAI_OrderInHouse()
                        {
                            ChcekProNo   = model.ProNo,
                            CreateTime   = DateTime.Now.AddSeconds(1),
                            CreateUserId = eform.appPer,
                            GuestName    = orders[0].GuestName,
                            HouseID      = objhouseId,
                            POName       = orders[0].POName,
                            PONo         = orders[0].PONo,
                            RuTime       = DateTime.Now.AddSeconds(1),
                            Status       = "通过",
                            Supplier     = orders[0].SupplierName,
                            DoPer        = orders[0].CaiGouPer,
                            DaiLi        = orders[0].CaiGouPer,
                            FPNo         = "",
                            Remark       = ""
                        };
                        List <CAI_OrderInHouses> ordersInHouses = new List <CAI_OrderInHouses>();
                        foreach (var m in orders)
                        {
                            CAI_OrderInHouses orderM = new CAI_OrderInHouses()
                            {
                                GooId            = m.CheckGoodId,
                                GoodNum          = m.CheckNum,
                                GoodPrice        = m.CheckPrice,
                                OrderCheckIds    = m.Ids,
                                QingGouPer       = m.QingGou,
                                CaiLastTruePrice = m.CheckLastTruePrice
                            };
                            ordersInHouses.Add(orderM);
                        }
                        orderInHouse.addTran(orderInModel, eformMain, ordersInHouses, objCommand);
                        if (ids != null)
                        {
                            foreach (var ordersIn in ordersInHouses)
                            {
                                ids.Add(ordersIn.Ids.ToString());
                            }
                        }
                    }

                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(0);
                }
                return(id);
            }
        }
コード例 #8
0
        /// <summary>
        /// 获得数据列表(比DataSet效率高,推荐使用)
        /// </summary>
        public List <VAN_OA.Model.JXC.CAI_OrderInHouse> GetListArray(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select tb2.IsHanShui,tb2.allCount,");
            strSql.Append(" CAI_OrderInHouse.Id,CAI_OrderInHouse.CreateUserId,CAI_OrderInHouse.CreateTime,RuTime,Supplier,DoPer,HouseID,houseName,ChcekProNo,ProNo,PONo,POName,Remark ,tb_User.loginName as CreateName,Status,FPNo,DaiLi ,GuestName,AE ");
            strSql.Append(" from CAI_OrderInHouse left join tb_User on tb_User.id=CAI_OrderInHouse.CreateUserId left join TB_HouseInfo on CAI_OrderInHouse.HouseID=TB_HouseInfo.id ");
            strSql.Append(" left join (select AE,PONO as CGPONO from CG_POOrder where IFZhui=0 and Status='通过') as tb on tb.CGPONO=CAI_OrderInHouse.PONO ");
            strSql.Append(@" left join 
 (
	
	select CAI_OrderInHouses.id,sum(CAI_POCai.IsHanShui) as IsHanShui ,COUNT(*) as allCount from CAI_OrderInHouses left join CAI_OrderChecks on CAI_OrderInHouses.OrderCheckIds=CAI_OrderChecks.Ids
	left join CAI_POCai on CAI_OrderChecks.CaiId=CAI_POCai.Ids
	group by CAI_OrderInHouses.id
 ) as 
 tb2 on tb2.id=CAI_OrderInHouse.Id ");

            //strSql.Append(" left join tb_EForm on tb_EForm.allE_id=CAI_OrderInHouse.id and proId=21 ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }

            strSql.Append(" order by CAI_OrderInHouse.Id desc");
            List <VAN_OA.Model.JXC.CAI_OrderInHouse> list = new List <VAN_OA.Model.JXC.CAI_OrderInHouse>();

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        CAI_OrderInHouse model = ReaderBind(dataReader);
                        object           ojb;
                        ojb = dataReader["houseName"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.HouseName = ojb.ToString();
                        }
                        ojb = dataReader["AE"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.AE = ojb.ToString();
                        }

                        ojb = dataReader["IsHanShui"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Count1 = (int)ojb;
                        }
                        ojb = dataReader["allCount"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Count2 = (int)ojb;
                        }

                        list.Add(model);
                    }
                }
            }
            return(list);
        }