/// <summary>
        /// 主表保存
        /// </summary>
        /// <returns></returns>
        public string MAINEdit()
        {
            string _OUT_ID = tbxOUT_ID.Text;

            try
            {
                var    model    = new OUT00(x => x.OUT_ID == _OUT_ID);
                var    OlUser   = OnlineUsersBll.GetInstence().GetModelForCache(x => x.UserHashKey == Session[OnlineUsersTable.UserHashKey].ToString());
                string _SHOP_ID = ddlSHOP_NAME.SelectedValue;
                if (String.IsNullOrEmpty(_OUT_ID))
                {
                    model.SetIsNew(true);
                    model.CRT_DATETIME = DateTime.Now;
                    model.CRT_USER_ID  = OlUser.Manager_LoginName;
                    DataTable dt = new DataTable();
                    dt             = (DataTable)SPs.Get_ORDER_SEED(_SHOP_ID, "OUT00").ExecuteDataTable();
                    _OUT_ID        = dt.Rows[0]["PLANE_ID"].ToString();
                    tbxOUT_ID.Text = _OUT_ID;
                    //var model = Purchase00.SingleOrDefault(x => x.Purchase_ID == _Pur00_id);
                }
                model.SHOP_ID    = _SHOP_ID;
                model.OUT_ID     = _OUT_ID.ToString();
                model.STATUS     = ConvertHelper.Cint(ddlStatus.SelectedValue);
                model.INPUT_DATE = ConvertHelper.StringToDatetime(dpINPUT_DATE.SelectedDate.ToString());

                model.IN_SHOP      = ddlIN_SHOP.SelectedValue;
                model.STOCK_ID     = ddlSTOCK_ID.SelectedValue;
                model.USER_ID      = OlUser.Manager_LoginName;
                model.APP_USER     = OlUser.Manager_LoginName;
                model.APP_DATETIME = tbxAPP_DATETIME.Text == "" ? DateTime.Parse("1900-01-01 00:00:00") : DateTime.Now;
                model.EXPECT_DATE  = ConvertHelper.StringToDatetime(dpEXPECT_DATE.SelectedDate.ToString());

                model.Exported    = ConvertHelper.StringToByte(cbExported.Checked ? "1" : "0");
                model.Exported_ID = tbxExported_ID.Text;
                string _RELATE_ID = tbxRELATE_ID.Text;
                model.RELATE_ID = _RELATE_ID;
                if (!String.IsNullOrEmpty(_RELATE_ID))
                {
                    var modelOrder = new ORDER00(x => x.ORDER_ID == _RELATE_ID);
                    modelOrder.EXPORTED = 1;
                    modelOrder.Save();
                }
                model.Memo   = tbxMemo.Text;
                model.LOCKED = ConvertHelper.StringToByte(ckLOCKED.Checked ? "1" : "0");

                model.MOD_DATETIME = DateTime.Now;
                model.MOD_USER_ID  = OlUser.Manager_LoginName;
                model.LAST_UPDATE  = DateTime.Now;
                model.Trans_STATUS = 0;
                OUT00Bll.GetInstence().Save(this, model);
                LoadMAIN();
            }
            catch (Exception err)
            {
                return(err.Message);
            }
            return("");
        }
Ejemplo n.º 2
0
        protected void ButtonApproval_Click(object sender, EventArgs e)
        {
            string str = GridViewHelper.GetSelectedKey(Grid1, true);

            string[] col_id_shop_id = str.Split(',');
            string   shop_id        = col_id_shop_id[1];
            string   col_id         = col_id_shop_id[0];

            int ex_int = OUT00Bll.GetInstence().SplitOrders(col_id);

            if (ex_int == 1)
            {
                Alert.Show("核准失败,请重新核准!");
            }
            else
            {
                Alert.Show("核准成功!");
            }
        }
 /// <summary>
 /// 初始化
 /// </summary>
 public override void Init()
 {
     bll = OUT00Bll.GetInstence();
     //throw new NotImplementedException();
 }
Ejemplo n.º 4
0
 public void SearchOrder()
 {
     //int type = ConvertHelper.Cint(FilterDateRadio.SelectedValue);
     OUT00Bll.GetInstence().BindGrid(Grid1, 0, 0, InquiryCondition(), sortList);
     //TAKEIN10Bll.GetInstence().BindOrderGrid(st, et, type, Grid1);
 }
Ejemplo n.º 5
0
        ///// <summary>
        ///// 更换分店事件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //protected void shopIdDropdown_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    LoadData();
        //}

        /// <summary>
        /// 汇整出货单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Archive_Click(object sender, EventArgs e)
        {
            archiveWindow.Hidden = true;

            //获取登录用户
            var OlUser = OnlineUsersBll.GetInstence().GetModelForCache(x => x.UserHashKey == Session[OnlineUsersTable.UserHashKey].ToString());

            //登录名
            string userId = OlUser.Manager_LoginName;

            //获取用户所属shop
            shopId = OlUser.SHOP_ID;

            DatePicker dpStart = archiveWindow.FindControl("archiveDatePanel").FindControl("outStartDate") as DatePicker;
            DatePicker dpEnd   = archiveWindow.FindControl("archiveDatePanel").FindControl("outEndDate") as DatePicker;

            //拼接查询条件
            List <ConditionFun.SqlqueryCondition> conditionList = QueryOutListCondition(shopId, dpStart.Text, dpEnd.Text);

            //1.查询总部出货表
            // 1)出货单状态为 2=核准
            // 2)SHOP_ID = 当前登录用户的总部编号
            // 3)在指定日期范围内
            //2.遍历结果
            //3.更新出货单状态为5=月结(关单), 并且锁定出货单(LOCKED=1)
            //4.更新成功后查询出货单明细更新到应收明细表
            //5.保存应收主信息
            //6.保存应收明细

            int total = 0;


            //循环查询
            while (true)
            {
                //1.查询满足条件的出货单
                DataTable dataTable = OUT00Bll.GetInstence().GetDataTable(false, 100, null, 0, 100, conditionList, null);
                if (dataTable == null || dataTable.Rows.Count == 0)
                {
                    break;
                }

                //2.遍历查询结果
                foreach (DataRow row in dataTable.Rows)
                {
                    try
                    {
                        //3.更新出货单状态为5=月结(关单)
                        int retValue = updaterHelper.Update(string.Format("update OUT00 set STATUS = 5, LOCKED = 1 where id = {0} and STATUS = 2", row["Id"]));

                        //更新成功 汇整出货单
                        if (retValue == 1)
                        {
                            //4.查询出货单明细
                            //明细查询条件
                            List <ConditionFun.SqlqueryCondition> itemConditionList = new List <ConditionFun.SqlqueryCondition>();
                            itemConditionList.Add(new ConditionFun.SqlqueryCondition(ConstraintType.Where, "SHOP_ID", Comparison.Equals, row["SHOP_ID"], false, false));
                            itemConditionList.Add(new ConditionFun.SqlqueryCondition(ConstraintType.And, "OUT_ID", Comparison.Equals, row["OUT_ID"], false, false));

                            //执行查询
                            List <OUT01> outItemList = selectHelper.Select <OUT01>(false, 0, null, itemConditionList, new List <string>()
                            {
                                "SNo"
                            }).ExecuteTypedList <OUT01>();

                            if (outItemList == null || outItemList.Count == 0)
                            {
                                CommonBll.WriteLog(string.Format("出货单{0}未查询到明细", row["OUT_ID"]), null);
                                continue;
                            }

                            //出货价格
                            decimal price = 0;
                            //出货成本
                            decimal cost = 0;
                            //遍历出货单明细插入
                            foreach (OUT01 item in outItemList)
                            {
                                //累加出货价
                                price += item.STD_PRICE;
                                //累加成本
                                cost += item.COST;

                                //应收明细
                                RECEIVABLES01 receiveItem = new RECEIVABLES01();
                                //出货批号
                                receiveItem.BAT_NO = item.BAT_NO;
                                //出货成本
                                receiveItem.COST = item.COST;
                                //明细备注
                                receiveItem.MEMO = item.MEMO;
                                //出货单ID
                                receiveItem.OUT_ID = item.OUT_ID;
                                //商品编号
                                receiveItem.PROD_ID = item.PROD_ID;
                                //验收量
                                receiveItem.QUAN1 = item.QUAN1;
                                //取消量
                                receiveItem.QUAN2 = item.QUAN2;
                                //总店编号
                                receiveItem.SHOP_ID = item.SHOP_ID;
                                //明细序号
                                receiveItem.SNo = item.SNo;
                                //出货价格
                                receiveItem.STD_PRICE = item.STD_PRICE;
                                //出货量
                                receiveItem.STD_QUAN = item.STD_QUAN;
                                //出货单位
                                receiveItem.STD_UNIT = item.STD_UNIT;

                                //6.保存明细
                                receiveItem.Save();
                            }

                            RECEIVABLES00 receiveMain = new RECEIVABLES00();
                            //receiveMain.APP_DATETIME
                            //receiveMain.APP_USER = "";
                            //建档时间
                            receiveMain.CRT_DATETIME = DateTime.Now;
                            //建档人员
                            receiveMain.CRT_USER_ID = userId;
                            //出货单日期
                            receiveMain.INPUT_DATE = (DateTime)row["INPUT_DATE"];
                            //分店编号
                            receiveMain.IN_SHOP = row["IN_SHOP"].ToString();
                            //最后修改日期
                            receiveMain.LAST_UPDATE = DateTime.Now;
                            //备注
                            receiveMain.MEMO = row["Memo"].ToString();
                            //修改时间
                            receiveMain.MOD_DATETIME = DateTime.Now;
                            //修改人
                            receiveMain.MOD_USER_ID = userId;
                            //出货单号
                            receiveMain.OUT_ID = row["OUT_ID"].ToString();
                            //总店编号
                            receiveMain.SHOP_ID = row["SHOP_ID"].ToString();
                            //新建存档状态
                            receiveMain.STATUS = 1;
                            //出货单的建单人
                            receiveMain.USER_ID = row["USER_ID"].ToString();
                            //出货总价
                            receiveMain.BILL_AMOUNT = price;
                            //出货总成本
                            receiveMain.BILL_COST = cost;

                            //5.保存应收账单
                            receiveMain.Save();
                            total++;
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonBll.WriteLog(string.Format("汇整出货单{0}发生错误。", row["OUT_ID"]), ex);
                    }
                }

                //已处理到最后一页
                if (dataTable.Rows.Count < 100)
                {
                    break;
                }
                //等待2秒
                Thread.Sleep(2000);
            }

            Thread.Sleep(5000);

            Alert.Show(string.Format("汇整完成,共汇整{0}条出货单.", total));
        }
        /// <summary>
        /// 查询应收账单
        /// </summary>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        private List <ReceiveBillMain> QueryOutBill(string startDate, string endDate, string userId)
        {
            //拼接查询条件
            List <ConditionFun.SqlqueryCondition> conditionList = QueryOutListCondition(shopId, startDate, endDate);

            //1.查询总部出货表OUT00
            // 1)出货单状态为 2=核准
            // 2)SHOP_ID = 当前登录用户的总部编号
            // 3)在指定日期范围内
            //2.遍历结果 计算成本和价格
            //3.显示预览界面


            List <ReceiveBillMain> previewList = new List <ReceiveBillMain>();


            //1.查询满足条件的出货单
            DataTable dataTable = OUT00Bll.GetInstence().GetDataTable(false, 5000, null, 0, 5000, conditionList, null);

            if (dataTable == null || dataTable.Rows.Count == 0)
            {
                return(previewList);
            }

            //2.遍历查询结果
            foreach (DataRow row in dataTable.Rows)
            {
                try
                {
                    //4.查询出货单明细
                    //明细查询条件
                    List <ConditionFun.SqlqueryCondition> itemConditionList = new List <ConditionFun.SqlqueryCondition>();
                    itemConditionList.Add(new ConditionFun.SqlqueryCondition(ConstraintType.Where, "SHOP_ID", Comparison.Equals, row["SHOP_ID"], false, false));
                    itemConditionList.Add(new ConditionFun.SqlqueryCondition(ConstraintType.And, "OUT_ID", Comparison.Equals, row["OUT_ID"], false, false));

                    //执行查询
                    List <OUT01> outItemList = selectHelper.Select <OUT01>(false, 0, null, itemConditionList, new List <string>()
                    {
                        "SNo"
                    }).ExecuteTypedList <OUT01>();

                    if (outItemList == null || outItemList.Count == 0)
                    {
                        CommonBll.WriteLog(string.Format("出货单{0}未查询到明细", row["OUT_ID"]), null);
                        continue;
                    }

                    //出货价格
                    decimal price = 0;
                    //出货成本
                    decimal cost = 0;
                    //遍历出货单明细插入
                    foreach (OUT01 item in outItemList)
                    {
                        //累加出货价
                        price += item.STD_PRICE;
                        //累加成本
                        cost += item.COST;
                    }

                    ReceiveBillMain receiveMain = new ReceiveBillMain();

                    receiveMain.Id        = Convert.ToInt32(row["Id"].ToString());
                    receiveMain.BILL_TYPE = (int)BillType.OutBill;
                    //建档时间
                    receiveMain.CRT_DATETIME = DateTime.Now;
                    //建档人员
                    receiveMain.CRT_USER_ID = userId;
                    //出货单日期
                    receiveMain.INPUT_DATE = (DateTime)row["INPUT_DATE"];
                    //分店编号
                    receiveMain.IN_SHOP = row["IN_SHOP"].ToString();
                    //最后修改日期
                    receiveMain.LAST_UPDATE = DateTime.Now;
                    //备注
                    receiveMain.MEMO = row["Memo"].ToString();
                    //修改时间
                    receiveMain.MOD_DATETIME = DateTime.Now;
                    //修改人
                    receiveMain.MOD_USER_ID = userId;
                    //出货单号
                    receiveMain.BILL_ID = row["OUT_ID"].ToString();
                    //总店编号
                    receiveMain.SHOP_ID = row["SHOP_ID"].ToString();
                    //新建存档状态
                    receiveMain.STATUS = 1;
                    //出货单的建单人
                    receiveMain.USER_ID = row["USER_ID"].ToString();
                    //出货总价
                    receiveMain.BILL_AMOUNT = price;
                    //出货总成本
                    receiveMain.BILL_COST = cost;

                    previewList.Add(receiveMain);
                }
                catch (Exception ex)
                {
                    CommonBll.WriteLog(string.Format("汇整出货单{0}发生错误。", row["OUT_ID"]), ex);
                }
            }

            return(previewList);
        }
Ejemplo n.º 7
0
 protected void ButtonOrderSearch_Click(Object sender, EventArgs e)
 {
     FineUI.Grid grid4 = Window4.FindControl("PanelGrid5").FindControl("Grid4") as FineUI.Grid;
     OUT00Bll.GetInstence().BindGrid(grid4, 0, 0, OrderCondition(), null);
 }