Beispiel #1
0
        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, ORDER01Table.ORDER_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");
                DataTable da = ORDER01Bll.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("OUT_ID01", tbxOUT_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_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["COST_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);
                }
            }
        }
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <returns></returns>
        public override string Save()
        {
            string result = string.Empty;
            int    id     = ConvertHelper.Cint0(hidId.Text);

            try
            {
                //判断
                if (ddlShop.SelectedValue == "0")
                {
                    return(ddlShop.Label + "不能为空!");
                }

                if (ddlOUT_SHOP.SelectedValue == "0")
                {
                    return(ddlOUT_SHOP.Label + "不能为空!");
                }

                if (ddlORDER_DEP.SelectedValue == "0")
                {
                    return(ddlORDER_DEP.Label + "不能为空!");
                }


                //订单编号
                if (txtORDER_ID.Text == "")
                {
                    Random ran = new Random();
                    txtORDER_ID.Text = ddlShop.SelectedValue + "OR" + DateTime.Now.ToString("yyyy-MM-dd").Replace("-", "") + ran.Next(1000, 9999);
                }

                string manager_LoginName = OnlineUsersBll.GetInstence().GetUserOnlineInfo("Manager_LoginName").ToString();//登录名

                txtAPP_USER.Text         = manager_LoginName;
                txtAPP_DATE.SelectedDate = DateTime.Now;

                string ORDER_ID = txtORDER_ID.Text; // GridViewHelper.GetSelectedKey(Grid2, true);

                //获取价格区域
                string shop_id    = OnlineUsersBll.GetInstence().GetUserOnlineInfo("SHOP_ID").ToString();
                var    model_SHOP = new SHOP00(x => x.SHOP_ID == shop_id);

                string prcarea_id = model_SHOP.SHOP_Price_Area;

                // 复制原始表格的结构
                DataTable newTable = GetSourceData(ORDER_ID, prcarea_id).Clone();
                DataRow   newRow;

                JArray mergedData = Grid1.GetMergedData();

                int i = 0;
                foreach (JObject mergedRow in mergedData)
                {
                    string  status   = mergedRow.Value <string>("status");
                    int     rowIndex = mergedRow.Value <int>("index");
                    JObject values   = mergedRow.Value <JObject>("values");

                    i         = i + 1;
                    newRow    = newTable.NewRow();
                    newRow[0] = rowIndex;//i;////j;// rowIndex; // 将行标识符设置为行索引号
                    newRow[1] = values.Value <string>("PROD_NAME1");
                    newRow[2] = values.Value <string>("PROD_ID");
                    newRow[3] = values.Value <string>("PROD_SPEC");
                    newRow[4] = values.Value <string>("PROD_UNIT");
                    newRow[5] = values.Value <string>("ON_QUAN");
                    newRow[6] = values.Value <string>("STD_PRICE");
                    newRow[7] = values.Value <string>("QUAN1");
                    newTable.Rows.Add(newRow);
                }

                // 更新数据源
                Session[KEY_FOR_DATASOURCE_SESSION] = newTable;

                labResult.Text = ""; // String.Format("用户修改的数据:<pre>{0}</pre>", Grid1.GetModifiedData().ToString(Newtonsoft.Json.Formatting.Indented));
                                     //   MessageBox.Show(this,String.Format("用户修改的数据:<pre>{0}</pre>", Grid1.GetModifiedData().ToString(Newtonsoft.Json.Formatting.Indented)));

                // DataTable table = GetSourceData();

                Grid1.DataSource = (DataTable)Session[KEY_FOR_DATASOURCE_SESSION];// table;
                Grid1.DataBind();

                #region 数据验证

                //判断列表
                DataTable dt = (DataTable)Session[KEY_FOR_DATASOURCE_SESSION];
                if (dt.Rows.Count <= 0 || Session[KEY_FOR_DATASOURCE_SESSION] == null)
                {
                    return("要货明细不能为空!");
                }

                #endregion

                //改变界面
                ddlStatus.SelectedValue = "1" + "";

                #region 赋值  主表

                var model = new ORDER00(x => x.ORDER_ID == ORDER_ID);

                model.SHOP_ID     = ddlShop.SelectedValue;
                model.ORDER_ID    = txtORDER_ID.Text;
                model.INPUT_DATE  = DateTime.Now; // ConvertHelper.StringToDatetime(txtINPUT_DATE.Text);
                model.ORD_USER    = txtORD_USER.Text;
                model.EXPECT_DATE = DateTime.Now; // ConvertHelper.StringToDatetime(txtEXPECT_DATE.Text);
                model.STATUS      = 1;
                model.ORD_TYPE    = ConvertHelper.Cint0(ddlORD_TYPE.SelectedValue);
                model.OUT_SHOP    = ddlOUT_SHOP.SelectedValue;
                model.EXPORTED_ID = txtEXPORTED_ID.Text;
                model.EXPORTED    = ConvertHelper.StringToByte(txtEXPORTED.Text);
                model.APP_USER    = txtAPP_USER.Text;
                model.APP_DATE    = DateTime.Now;//ConvertHelper.StringToDatetime(txtAPP_DATE.Text);
                model.Memo        = txtMemo.Text;
                model.LOCKED      = ConvertHelper.StringToByte(cbLOCKED.Checked.ToString());

                model.ORD_DEP_ID   = ddlORDER_DEP.SelectedValue;
                model.CRT_DATETIME = DateTime.Now; //ConvertHelper.StringToDatetime(txtCRT_DATETIME.Text);
                model.CRT_USER_ID  = txtCRT_USER_ID.Text;
                model.MOD_DATETIME = DateTime.Now; //ConvertHelper.StringToDatetime(txtMOD_DATETIME.Text);
                model.MOD_USER_ID  = txtMOD_USER_ID.Text;
                model.LAST_UPDATE  = DateTime.Now; //ConvertHelper.StringToDatetime(txtLAST_UPDATE.Text);
                model.Trans_STATUS = 0;

                #endregion

                //----------------------------------------------------------
                //存储到数据库
                ORDER00Bll.GetInstence().Save(this, model);

                //清空子表
                ORDER00Bll.GetInstence().Delete(model.ORDER_ID);

                #region 添加子表

                JArray mergedData1 = Grid1.GetMergedData();
                int    f           = mergedData.Count;

                int k = 0;
                foreach (JObject mergedRow in mergedData1)
                {
                    string  status   = mergedRow.Value <string>("status");
                    int     rowIndex = mergedRow.Value <int>("index");
                    JObject values   = mergedRow.Value <JObject>("values");

                    k = k + 1;

                    var model_1 = new ORDER01(x => x.SNo == k && x.ORDER_ID == txtORDER_ID.Text.Trim());

                    model_1.SNo = k;// rowIndex + 1;

                    model_1.SHOP_ID  = ddlShop.SelectedValue;
                    model_1.ORDER_ID = txtORDER_ID.Text.Trim();

                    model_1.PROD_ID      = values.Value <string>("PROD_ID");
                    model_1.QUANTITY     = 0;
                    model_1.ON_QUAN      = ConvertHelper.StringToDecimal(values.Value <string>("ON_QUAN"));
                    model_1.QUAN1        = ConvertHelper.StringToDecimal(values.Value <string>("QUAN1"));//小计
                    model_1.QUAN2        = 0;
                    model_1.COST_PRICE   = ConvertHelper.StringToDecimal(values.Value <string>("STD_PRICE"));
                    model_1.STD_UNIT     = values.Value <string>("PROD_UNIT");
                    model_1.STD_CONVERT  = 0;
                    model_1.STD_QUAN     = ConvertHelper.StringToDecimal(values.Value <string>("ON_QUAN"));
                    model_1.STD_PRICE    = ConvertHelper.StringToDecimal(values.Value <string>("STD_PRICE"));
                    model_1.Memo         = "";
                    model_1.CRT_DATETIME = DateTime.Now;
                    model_1.CRT_USER_ID  = txtCRT_USER_ID.Text;
                    model_1.MOD_DATETIME = DateTime.Now;
                    model_1.MOD_USER_ID  = txtMOD_USER_ID.Text;

                    //----------------------------------------------------------
                    //存储到数据库
                    ORDER01Bll.GetInstence().Save(this, model_1);
                }

                ///grid2

                conditionList = new List <ConditionFun.SqlqueryCondition>();
                conditionList.Add(new ConditionFun.SqlqueryCondition(ConstraintType.Where, ORDER00Table.SHOP_ID, Comparison.Equals, shop_id, false, false));

                //  ORDER00Bll.GetInstence().BindGrid(Grid2, 0, sortList);
                // bll.BindGrid(Grid2, 0, sortList);
                ORDER00Bll.GetInstence().BindGrid(Grid2, 0, 0, conditionList, sortList);

                #endregion
            }
            catch (Exception e)
            {
                result = "保存失败!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }

            return(result);
        }
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <returns></returns>
        public override string Save()
        {
            string result   = string.Empty;
            string order_id = hidId.Text;

            try
            {
                #region 数据验证

                if (ddlPROD_NAME1.Text.Trim() == "请选择商品名称")
                {
                    return(ddlPROD_NAME1.Label + "请选择商品名称!");
                }

                if (string.IsNullOrEmpty(txtPROD_ID.Text.Trim()))
                {
                    return(txtPROD_ID.Label + "不能为空!");
                }

                if (string.IsNullOrEmpty(txtPROD_UNIT.Text.Trim()))
                {
                    return(txtPROD_UNIT.Label + "不能为空!");
                }

                if (string.IsNullOrEmpty(txtU_Cost.Text.Trim()))
                {
                    return(txtU_Cost.Label + "不能为空!");
                }

                if (string.IsNullOrEmpty(txtOrder_QUAN.Text.Trim()))
                {
                    return(txtOrder_QUAN.Label + "不能为空!");
                }

                #endregion

                #region 赋值

                int id = ConvertHelper.Cint0(RequestHelper.GetQueryString("Id"));
                //读取资料
                var model_0 = new ORDER00(x => x.ORDER_ID == order_id);

                var model = new ORDER01(x => x.ORDER_ID == order_id && x.Id == id);

                model.SHOP_ID = model_0.SHOP_ID;//分店编号

                //序号
                conditionList = new List <ConditionFun.SqlqueryCondition>();
                conditionList.Add(new ConditionFun.SqlqueryCondition(ConstraintType.Where, ORDER01Table.ORDER_ID, Comparison.Equals, order_id, false, false));
                model.SNo = ORDER01Bll.GetInstence().GetRecordCount(conditionList) + 1;

                model.PROD_ID     = txtPROD_ID.Text.Trim();
                model.ORDER_ID    = order_id;
                model.ON_QUAN     = ConvertHelper.StringToDecimal(txtON_QUAN.Text.Trim());
                model.QUAN1       = 0;
                model.QUAN2       = 0;
                model.COST_PRICE  = 0;
                model.STD_UNIT    = txtPROD_UNIT.Text;
                model.STD_CONVERT = 0;

                model.QUANTITY = model.STD_QUAN * model.STD_CONVERT;

                model.STD_QUAN  = ConvertHelper.StringToDecimal(txtON_QUAN.Text);
                model.STD_PRICE = ConvertHelper.StringToDecimal(txtU_Cost.Text);
                model.Memo      = txtMemo.Text;

                model.CRT_DATETIME = DateTime.Now;
                model.CRT_USER_ID  = OnlineUsersBll.GetInstence().GetManagerCName();
                model.MOD_DATETIME = DateTime.Now;
                model.MOD_USER_ID  = OnlineUsersBll.GetInstence().GetManagerCName();


                #endregion

                //----------------------------------------------------------
                //存储到数据库
                ORDER01Bll.GetInstence().Save(this, model);


                //   PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            catch (Exception e)
            {
                result = "保存失败!";

                //出现异常,保存出错日志信息
                //  CommonBll.WriteLog(result, e);
            }

            return(result);
        }
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <returns></returns>
        public override string Save()
        {
            string result   = string.Empty;
            string order_id = hidId.Text;

            try
            {
                #region 数据验证


                //  FineUI.DropDownList dddlPROD_NAME1 = Window2.FindControl("ddlPROD_NAME1") as FineUI.DropDownList;
                if (ddlPROD_NAME1.SelectedText == "请选择")
                {
                    return(ddlPROD_NAME1.Label + "请选择!");
                }

                //  FineUI.TextBox ttxtPROD_ID = Window2.FindControl("txtPROD_ID") as FineUI.TextBox;
                if (string.IsNullOrEmpty(txtPROD_ID.Text.Trim()))
                {
                    return(txtPROD_ID.Label + "不能为空!");
                }

                // FineUI.TextBox ttxtPROD_UNIT = Window2.FindControl("txtPROD_UNIT") as FineUI.TextBox;
                if (string.IsNullOrEmpty(txtPROD_UNIT.Text.Trim()))
                {
                    return(txtPROD_UNIT.Label + "不能为空!");
                }

                // FineUI.TextBox ttxtTotal = Window2.FindControl("txtTotal") as FineUI.TextBox;
                if (string.IsNullOrEmpty(txtTotal.Text.Trim()))
                {
                    return(txtTotal.Label + "不能为空!");
                }

                // FineUI.TextBox ttxtU_Cost = Window2.FindControl("txtU_Cost") as FineUI.TextBox;
                if (string.IsNullOrEmpty(txtU_Cost.Text.Trim()))
                {
                    return(txtU_Cost.Label + "不能为空!");
                }

                // FineUI.TextBox ttxtOrder_QUAN = Window2.FindControl("txtOrder_QUAN") as FineUI.TextBox;
                if (string.IsNullOrEmpty(txtOrder_QUAN.Text.Trim()))
                {
                    return(txtOrder_QUAN.Label + "不能为空!");
                }

                //  FineUI.TextBox ttxtON_QUAN = Window2.FindControl("txtON_QUAN") as FineUI.TextBox;
                if (string.IsNullOrEmpty(txtON_QUAN.Text.Trim()) || txtON_QUAN.Text == "0")
                {
                    return(txtON_QUAN.Label + "不能为空或者0!");
                }


                //  FineUI.TextBox ttxtMemo = Window2.FindControl("txtMemo") as FineUI.TextBox;

                #endregion

                #region 赋值

                int id = ConvertHelper.Cint0(SNo.Text);
                //读取资料
                var model_0 = new ORDER00(x => x.ORDER_ID == order_id);

                //序号
                conditionList = new List <ConditionFun.SqlqueryCondition>();
                conditionList.Add(new ConditionFun.SqlqueryCondition(ConstraintType.Where, ORDER01Table.ORDER_ID, Comparison.Equals, order_id, false, false));


                if (IsEdit)
                {
                    id = ConvertHelper.Cint0(GridViewHelper.GetSelectedKey(Grid2, true));
                }
                else
                {
                    id = ORDER01Bll.GetInstence().GetRecordCount(conditionList) + 1;
                }

                var model = new ORDER01(x => x.ORDER_ID == order_id && x.SNo == id);

                model.SHOP_ID = model_0.SHOP_ID;//分店编号
                model.SNo     = id;


                model.PROD_ID     = txtPROD_ID.Text.Trim();
                model.ORDER_ID    = order_id;
                model.ON_QUAN     = ConvertHelper.StringToDecimal(txtON_QUAN.Text.Trim());
                model.QUAN1       = ConvertHelper.StringToDecimal(txtTotal.Text);
                model.QUAN2       = 0;
                model.COST_PRICE  = 0;
                model.STD_UNIT    = txtPROD_UNIT.Text;
                model.STD_CONVERT = 0;

                model.QUANTITY = model.STD_QUAN * model.STD_CONVERT;

                model.STD_QUAN  = ConvertHelper.StringToDecimal(txtON_QUAN.Text);
                model.STD_PRICE = ConvertHelper.StringToDecimal(txtU_Cost.Text);
                model.Memo      = txtMemo.Text;

                model.CRT_DATETIME = DateTime.Now;
                model.CRT_USER_ID  = OnlineUsersBll.GetInstence().GetManagerCName();
                model.MOD_DATETIME = DateTime.Now;
                model.MOD_USER_ID  = OnlineUsersBll.GetInstence().GetManagerCName();


                #endregion

                //----------------------------------------------------------
                //存储到数据库
                ORDER01Bll.GetInstence().Save(this, model);

                //   Window2.Hidden = true;

                BindGrid2();
                MessageBox.Show(this, "保存成功!");

                //   PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            catch (Exception e)
            {
                result = "保存失败!";

                //出现异常,保存出错日志信息
                //  CommonBll.WriteLog(result, e);
            }

            return(result);
        }