Exemplo n.º 1
0
        private void DetailTextBoxToModel(TPurchaseIndentDetail tinfo)
        {
            MMS_PurchaseIndentDetail detail = tinfo.DetDetail;

            detail.PurchaseBillCode = txtPurchasePlanBillCode.Text; //入库单号
            detail.ProductCode      = txtProductCode.Text;          //货品代码
            if (!string.IsNullOrEmpty(txtQuantity.Text))            //数量
            {
                detail.Quantity = Convert.ToInt32(txtQuantity.Text);
            }
            detail.Memo         = txtComm.Text.ToString().Trim();
            detail.AuditAccount = FindListAuditUser(txtProductCode.Text.ToString()).ToString();
        }
Exemplo n.º 2
0
        private void ModelToDetailTextBox(TPurchaseIndentDetail tinfo)
        {
            //调用业务层方法取货品信息实体
            MMS_MaterialInfo         Material = MaterialInfoService.Instance.GetProductInfoByCode(tinfo.DetDetail.ProductCode);
            MMS_PurchaseIndentDetail detail   = tinfo.DetDetail;

            txtProductCode.Text = detail.ProductCode;              //货品代码
            txtShortName.Text   = Material.Material_Name;          //货品简称
            txtSpecs.Text       = Material.Material_Specification; //规格
            ddlUnit.Text        = Material.Material_Unit;          //计量单位
            txtVendor.Text      = Material.Material_Supplier;      //供应商
            txtQuantity.Text    = detail.Quantity.ToString();      //数量
        }
Exemplo n.º 3
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            TPurchaseIndent info = _TPurchaseIndent;

            if (string.IsNullOrEmpty(detailId)) //插入操作
            {
                //创建入库货品实例
                TPurchaseIndentDetail tinfoDetail = new TPurchaseIndentDetail();
                tinfoDetail.DetDetail = new MMS_PurchaseIndentDetail();
                if (info.Detail.Count > 0) //新插入的以-1开始,以后渐减
                {
                    //设置新录入入库货品的主键ID,以-1开始,以后渐减
                    int minId = info.Detail.Min(itm => itm.DetDetail.ID);
                    if (minId < 0)
                    {
                        tinfoDetail.DetDetail.ID = minId - 1;
                    }
                    else
                    {
                        tinfoDetail.DetDetail.ID = -1;
                    }
                }
                else //该入库单没有货品信息
                {
                    tinfoDetail.DetDetail.ID = -1;
                }
                DetailTextBoxToModel(tinfoDetail); //将入库货品赋值给实体
                tinfoDetail.OprType = OperateType.otInsert;
                info.Detail.Add(tinfoDetail);      //将操作实体添加到入库货品集合中
                _TPurchaseIndent = info;

                ClearDetailTextBox(); //清除入库货品服务器控件内容
                LoadData();           //加载Gridview数据
            }
            else //编辑操作
            {
                //根据入库货品ID取实体
                TPurchaseIndentDetail tinfoDetail = info.Detail.First(itm => itm.DetDetail.ID == Convert.ToInt32(detailId));
                DetailTextBoxToModel(tinfoDetail);               //将服务器控件赋给实体
                if (tinfoDetail.OprType != OperateType.otInsert) //如果是新插入的仍保留插入状态
                {
                    tinfoDetail.OprType = OperateType.otUpdate;
                }
                _TPurchaseIndent = info;
                LoadData();                  //加载GridView数据
                EntryDetailInputPage(false); //切换到入库单录入页面
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///   获得组合实体
        /// </summary>
        /// <param name="id"> 实体id号 </param>
        /// <returns> 自定义组合实体 </returns>
        public TPurchaseIndent GetPurchaseIndent(int id)
        {
            TPurchaseIndent resu = new TPurchaseIndent();

            resu.OprType = OperateType.otNone;
            resu.Content = dc.MMS_PurchaseIndentContent.Where(itm => itm.ID == id).First();

            List <MMS_PurchaseIndentDetail> tempList =
                dc.MMS_PurchaseIndentDetail.Where(itm => itm.PurchaseBillCode == resu.Content.PurchaseBillCode).ToList();

            foreach (MMS_PurchaseIndentDetail item in tempList)
            {
                TPurchaseIndentDetail TDetail = new TPurchaseIndentDetail();
                TDetail.OprType   = OperateType.otNone;
                TDetail.DetDetail = item;
                resu.Detail.Add(TDetail);
            }
            return(resu);
        }
Exemplo n.º 5
0
        /// <summary>
        ///   GridView行命令事件,点击GridView行按钮时触发的事件
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"> </param>
        protected void dgvInfo_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.CommandName))                     //判断命令名是否为空
            {
                if (e.CommandName == "Edi")                               //如果触发的是详细信息按钮事件
                {
                    int      index  = Convert.ToInt32(e.CommandArgument); //取GridView行索引
                    GridView grid   = (GridView)e.CommandSource;          //取当前操作的GridView
                    int      tempId = Convert.ToInt32(grid.DataKeys[index].Value);
                    detailId = tempId.ToString();
                    TPurchaseIndentDetail detail = _TPurchaseIndent.Detail.FirstOrDefault(itm => itm.DetDetail.ID == tempId);
                    ModelToDetailTextBox(detail); //将实体赋值给对应的服务器控件
                    EntryDetailInputPage(true);   //切换到货品录入页面
                }
                else if (e.CommandName == "Del")
                {
                    int      index = Convert.ToInt32(e.CommandArgument);          //取GridView行索引
                    GridView grid  = (GridView)e.CommandSource;                   //取当前操作的GridView
                    int      id    = Convert.ToInt32(grid.DataKeys[index].Value); //取GridView主键值

                    TPurchaseIndent       temp       = _TPurchaseIndent;
                    TPurchaseIndentDetail tempDetail = temp.Detail.First(itm => itm.DetDetail.ID == id);
                    if (tempDetail.OprType == OperateType.otInsert) //如果是新插入的直接将其删除
                    {
                        temp.Detail.Remove(tempDetail);
                    }
                    else //如是不是新插入的置删除标志
                    {
                        tempDetail.OprType = OperateType.otDelete;
                    }
                    _TPurchaseIndent = temp;
                    LoadData();
                }
                else if (e.CommandName == "Page")
                {
                    LoadData();
                }
            }
        }