/// <summary>
        /// 子表保存
        /// </summary>
        /// <returns></returns>
        public string DetailEdit()
        {
            JArray jarr   = Grid2.GetMergedData();
            var    OlUser = OnlineUsersBll.GetInstence().GetModelForCache(x => x.UserHashKey == Session[OnlineUsersTable.UserHashKey].ToString());
            string result = "";
            int    n      = 0;

            for (int i = 0; i < jarr.Count; i++)
            {
                try
                {
                    int id     = ConvertHelper.Cint(jarr[i]["values"]["Id01"].ToString());
                    var model2 = new OUT_BACK01(x => x.Id == id);
                    //string str = jarr[i]["status"].ToString();
                    if (jarr[i]["status"].ToString().Equals("modified"))
                    {
                        model2.SetIsNew(false);
                    }
                    else if (jarr[i]["status"].ToString().Equals("unchanged"))
                    {
                        continue;
                    }
                    else
                    {
                        model2.SetIsNew(true);
                    }
                    model2.SHOP_ID = jarr[i]["values"]["SHOP_ID01"].ToString();
                    if (!String.IsNullOrEmpty(jarr[i]["values"]["BK_ID01"].ToString()))
                    {
                        model2.BK_ID = jarr[i]["values"]["BK_ID01"].ToString();
                    }
                    else
                    {
                        return("保存失败");
                    }
                    model2.SNo          = ConvertHelper.Cint(jarr[i]["values"]["SNo01"].ToString());
                    model2.PROD_ID      = jarr[i]["values"]["PROD_ID01"].ToString();
                    model2.QUANTITY     = ConvertHelper.Cdbl(jarr[i]["values"]["QUANTITY01"].ToString());
                    model2.STD_UNIT     = jarr[i]["values"]["STD_UNIT01"].ToString();
                    model2.STD_CONVERT  = ConvertHelper.Cint(jarr[i]["values"]["STD_CONVERT01"].ToString());
                    model2.STD_QUAN     = ConvertHelper.StringToDecimal(jarr[i]["values"]["STD_QUAN01"].ToString());
                    model2.STD_PRICE    = ConvertHelper.StringToDecimal(jarr[i]["values"]["STD_PRICE01"].ToString());
                    model2.COST         = ConvertHelper.StringToDecimal(jarr[i]["values"]["COST01"].ToString());
                    model2.QUAN1        = ConvertHelper.StringToDecimal(jarr[i]["values"]["QUAN101"].ToString());
                    model2.QUAN2        = ConvertHelper.StringToDecimal(jarr[i]["values"]["QUAN201"].ToString());
                    model2.MEMO         = jarr[i]["values"]["MEMO01"].ToString();
                    model2.REASON_ID    = jarr[i]["values"]["REASON_ID01"].ToString();
                    model2.BAT_NO       = jarr[i]["values"]["BAT_NO"].ToString();
                    model2.Exp_DateTime = DateTime.Now;
                    OUT_BACK01Bll.GetInstence().Save(this, model2);
                }
                catch (Exception err)
                {
                    n++;
                    result = "明细保存失败" + n + "条";
                }
            }
            LoadDETAIL();
            return(result);
        }
        /// <summary>
        /// 明细删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btn_DetailDelete(Object sender, EventArgs e)
        {
            string[] eCell = Grid2.SelectedCell;
            if (eCell == null)
            {
                FineUI.Alert.ShowInParent("请先选中一个删除项", FineUI.MessageBoxIcon.Information);
                return;
            }
            string a = Grid2.SelectedRowID;

            JArray    upJson = Grid2.GetMergedData();
            DataTable da     = new DataTable();

            for (int i = 0; i < upJson.Count; i++)
            {
                if (upJson[i]["status"].ToString() != "newadded" && upJson[i]["id"].ToString() == eCell[0].ToString())
                {
                    int _id = ConvertHelper.Cint(upJson[i]["values"]["Id01"].ToString());
                    //FineUI.Alert.ShowInParent(_id.ToString(), FineUI.MessageBoxIcon.Information);
                    Grid2.DeleteSelectedRows();
                    OUT_BACK01Bll.GetInstence().Delete(this, _id);
                    //hidORDDEP_ID.Text = "";
                    break;
                }
                else if (upJson[i]["status"].ToString() == "newadded" && upJson[i]["id"].ToString() == eCell[0].ToString())
                {
                    Grid2.DeleteSelectedRows();
                    //hidORDDEP_ID.Text = "";
                    break;
                }
            }
        }
        public void LoadDETAIL()
        {
            string _tbxBK_ID = tbxBK_ID.Text;

            if (!String.IsNullOrEmpty(_tbxBK_ID))
            {
                List <ConditionFun.SqlqueryCondition> conditiondetail = new List <ConditionFun.SqlqueryCondition>();
                conditiondetail.Add(new ConditionFun.SqlqueryCondition(ConstraintType.Where, OUT_BACK01Table.BK_ID, Comparison.Equals, _tbxBK_ID, false, false));
                OUT_BACK01Bll.GetInstence().BindGrid(Grid2, 0, 0, conditiondetail, sortList);
            }
        }
        protected void ButtonOrderAdd_Click(Object sender, EventArgs e)
        {
            FineUI.Grid Grid4      = Window4.FindControl("PanelGrid5").FindControl("Grid4") as FineUI.Grid;
            int[]       selections = Grid4.SelectedRowIndexArray;
            tbxRELATE_ID.Text = Grid4.DataKeys[0][0].ToString();
            foreach (int i in selections)
            {
                List <ConditionFun.SqlqueryCondition> order00con = new List <ConditionFun.SqlqueryCondition>();
                order00con.Add(new ConditionFun.SqlqueryCondition(ConstraintType.Where, OUT_BACK01Table.BK_ID, Comparison.Equals, Grid4.DataKeys[i][0].ToString(), false, false));
                List <string> colList = new List <string>();
                colList.Add("SHOP_ID");
                colList.Add("PROD_ID");
                colList.Add("QUANTITY");
                colList.Add("STD_UNIT");
                colList.Add("STD_CONVERT");
                colList.Add("STD_QUAN");
                colList.Add("STD_PRICE");
                //colList.Add("COST_PRICE");
                //colList.Add("");预留采购单位类别
                DataTable da = OUT_BACK01Bll.GetInstence().GetDataTable(false, 0, colList, 0, 0, order00con, null);

                foreach (DataRow dr in da.Rows)
                {
                    string  _shopid  = dr["SHOP_ID"].ToString();
                    string  _PROD_ID = dr["PROD_ID"].ToString();
                    var     model    = new SHOP00(x => x.SHOP_ID == _shopid);
                    var     model2   = new PRODUCT00(x => x.PROD_ID == _PROD_ID);
                    int     rowCount = Grid2.Rows.Count;
                    JObject deObject = new JObject();
                    deObject.Add("Id01", "0");
                    deObject.Add("SHOP_ID01", dr["SHOP_ID"].ToString());
                    deObject.Add("SHOP_NAME01", model.SHOP_NAME1);
                    deObject.Add("IB_ID01", tbxIB_ID.Text);
                    deObject.Add("SNo01", rowCount + 1);
                    deObject.Add("PROD_ID01", dr["PROD_ID"].ToString());
                    deObject.Add("PROD_NAME01", model2.PROD_NAME1);
                    deObject.Add("QUANTITY01", dr["QUANTITY"].ToString());
                    deObject.Add("STD_TYPE01", dr["STD_UNIT"].ToString());
                    deObject.Add("STD_UNIT01", dr["STD_UNIT"].ToString());
                    deObject.Add("STD_CONVERT01", dr["STD_CONVERT"].ToString());
                    deObject.Add("STD_QUAN01", dr["STD_QUAN"].ToString());
                    deObject.Add("STD_PRICE01", dr["STD_PRICE"].ToString());
                    deObject.Add("COST01", dr["STD_PRICE"].ToString());
                    deObject.Add("QUAN101", dr["STD_QUAN"].ToString());
                    deObject.Add("QUAN201", dr["STD_QUAN"].ToString());
                    deObject.Add("MEMO01", "");
                    deObject.Add("BAT_NO", "");
                    Grid2.AddNewRecord(deObject, true);
                }
            }
        }