コード例 #1
0
        private void AddStockQuantity(PurchaseDetailInfo detailInfo)
        {
            string wareHourse = this.txtWareHouse.Text;

            BLLFactory <Stock> .Instance.AddStockQuantiy(detailInfo.ItemNo, detailInfo.ItemName,
                                                         Convert.ToInt32(detailInfo.Quantity), wareHourse);//出库要减去相应的库存
        }
コード例 #2
0
ファイル: FrmAddPurchaseItem.cs プロジェクト: yyan/winform
        private void lvwDetail_OnEditSelected(object sender, EventArgs e)
        {
            PurchaseDetailInfo info = lvwDetail.gridView1.GetFocusedRow() as PurchaseDetailInfo;

            if (info != null)
            {
                FrmSetPurchaseQuantity dlg = new FrmSetPurchaseQuantity();
                dlg.txtItemNo.Text   = info.ItemNo;
                dlg.txtItemName.Text = info.ItemName;
                dlg.txtQuantity.Text = info.Quantity.ToString();
                dlg.txtPrice.Text    = info.Price.ToString("f2");

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    int     quntity = Convert.ToInt32(dlg.txtQuantity.Text);
                    decimal price   = Convert.ToDecimal(dlg.txtPrice.Text);

                    info.Price    = price;
                    info.Quantity = quntity;
                    lvwGoods.Refresh();

                    //入库的时候,数量,单价可以修改,因此需要重新获取单价信息,作为标准单价
                    PurchaseDetailInfo tempInfo = detailDict[info.ItemNo];
                    tempInfo.Amount   = price * quntity;
                    tempInfo.Quantity = quntity;
                    tempInfo.Price    = price;

                    ShowGoodDetailView();
                }
            }
        }
コード例 #3
0
ファイル: FrmPurchase.cs プロジェクト: 15831944/winform-1
        private void menu_ModifyStockPos_Click(object sender, EventArgs e)
        {
            if (this.lvwDetail.gridView1.GetSelectedRows().Length == 0)
            {
                return;
            }

            FrmSetStoragePos dlg = new FrmSetStoragePos();

            dlg.txtNewStoragePos.Text = "";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < this.lvwDetail.gridView1.RowCount; i++)
                {
                    PurchaseDetailInfo info = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo;
                    if (info != null)
                    {
                        // TODO
                        //this.lvwDetail.SelectedItems[i].SubItems[12].Text = dlg.txtNewStoragePos.Text;
                        //info.StoragePos = dlg.txtNewStoragePos.Text;
                        //this.lvwDetail.Items[i].Tag = info;
                    }
                }
            }
        }
コード例 #4
0
        private void menu_ModifyStockPos_Click(object sender, EventArgs e)
        {
            if (this.lvwDetail.SelectedItems.Count == 0)
            {
                return;
            }

            FrmSetStoragePos dlg = new FrmSetStoragePos();

            dlg.txtNewStoragePos.Text = "";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < this.lvwDetail.SelectedItems.Count; i++)
                {
                    PurchaseDetailInfo info = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                    if (info != null)
                    {
                        this.lvwDetail.SelectedItems[i].SubItems[12].Text = dlg.txtNewStoragePos.Text;
                        info.StoragePos             = dlg.txtNewStoragePos.Text;
                        this.lvwDetail.Items[i].Tag = info;
                    }
                }
            }
        }
コード例 #5
0
        private void NormalExport()
        {
            string    columns = @"流水号,备注,供货商,操作员,库房名称,备件编号(pm码),备件名称,图号,规格型号,材质,备件属类,备件类别,单位,最新单价(元),出库数量,总价,出库日期,来源,库位,成本中心,使用位置";
            DataTable dt      = DataTableHelper.CreateTable(columns);
            DataRow   row     = null;

            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo info = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (info != null)
                {
                    row              = dt.NewRow();
                    row["流水号"]       = this.txtHandNo.Text;
                    row["备注"]        = this.txtNote.Text;
                    row["供货商"]       = this.txtManufacture.Text;
                    row["操作员"]       = this.txtCreator.Text;
                    row["库房名称"]      = this.txtWareHouse.Text;
                    row["备件编号(pm码)"] = info.ItemNo;
                    row["备件名称"]      = info.ItemName;
                    row["图号"]        = info.MapNo;
                    row["规格型号"]      = info.Specification;
                    row["材质"]        = info.Material;
                    row["备件属类"]      = info.ItemBigType;
                    row["备件类别"]      = info.ItemType;
                    row["单位"]        = info.Unit;
                    row["最新单价(元)"]   = info.Price.ToString("C2");
                    row["出库数量"]      = info.Quantity.ToString();
                    row["总价"]        = info.Amount.ToString("C2");
                    row["出库日期"]      = this.txtCreateDate.DateTime.ToString();
                    row["来源"]        = info.Source;
                    row["库位"]        = info.StoragePos;
                    row["成本中心"]      = this.txtCostCenter.Text;
                    row["使用位置"]      = info.UsagePos;
                    dt.Rows.Add(row);
                }
            }

            try
            {
                string fileName = FileDialogHelper.SaveExcel();
                string outError = "";
                AsposeExcelTools.DataTableToExcel2(dt, fileName, out outError);
                if (!string.IsNullOrEmpty(outError))
                {
                    MessageDxUtil.ShowError(outError);
                    LogTextHelper.Error(outError);
                }
                else
                {
                    Process.Start(fileName);
                }
            }
            catch (Exception ex)
            {
                MessageDxUtil.ShowError(ex.Message);
                LogTextHelper.Error(ex);
            }
        }
コード例 #6
0
        private void btnPrintBill_Click(object sender, EventArgs e)
        {
            PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();

            headInfo.CreateDate    = txtCreateDate.DateTime;
            headInfo.Creator       = this.txtCreator.Text;
            headInfo.HandNo        = this.txtHandNo.Text;
            headInfo.Manufacture   = this.txtManufacture.Text;
            headInfo.Note          = this.txtNote.Text;
            headInfo.OperationType = "入库";
            headInfo.WareHouse     = this.txtWareHouse.Text;
            headInfo.CreateYear    = DateTime.Now.Year;
            headInfo.CreateMonth   = DateTime.Now.Month;

            List <PurchaseDetailInfo> detailList = new List <PurchaseDetailInfo>();

            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    StockInfo stockInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.Text);

                    if (stockInfo != null)
                    {
                        int            oldQuantity = stockInfo.StockQuantity;
                        decimal        oldPrice    = 0M;
                        ItemDetailInfo info        = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo);

                        if (info != null)
                        {
                            oldPrice = info.Price;
                            decimal newPrice = ((Convert.ToInt32(detailInfo.Quantity) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Quantity) + oldQuantity);

                            detailInfo.Price = newPrice;
                        }
                    }

                    detailList.Add(detailInfo);
                }
            }

            ReportViewerDialog dlg = new ReportViewerDialog();

            dlg.DataSourceDict.Add("PurchaseHeaderInfo", new List <PurchaseHeaderInfo>()
            {
                headInfo
            });
            dlg.DataSourceDict.Add("PurchaseDetailInfo", detailList);
            dlg.ReportFilePath = "Report/WHC.WareHouseMis.PurchaseReport.rdlc";

            dlg.Parameters.Add("CompanyName", this.AppInfo.AppUnit);
            dlg.ShowDialog();
        }
コード例 #7
0
ファイル: FrmPurchase.cs プロジェクト: 15831944/winform-1
        private void btnPrintBill_Click(object sender, EventArgs e)
        {
            PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();

            headInfo.CreatorTime   = txtCreateDate.DateTime;
            headInfo.CreatorId     = this.txtCreator.Text.ToInt32();
            headInfo.OrderNo       = this.txtHandNo.Text;
            headInfo.Manufacture   = this.txtManufacture.Text;
            headInfo.Remark        = this.txtNote.Text;
            headInfo.OperationType = (short)OperationType.新增;
            headInfo.WareHouseId   = this.txtWareHouse.GetComboBoxStrValue().ToInt32();
            headInfo.CreatorYear   = DateTimeHelper.GetServerDateTime2().Year;
            headInfo.CreatorMonth  = (short)DateTimeHelper.GetServerDateTime2().Month;

            List <PurchaseDetailInfo> detailList = new List <PurchaseDetailInfo>();

            for (int i = 0; i < this.lvwDetail.gridView1.RowCount; i++)
            {
                PurchaseDetailInfo detailInfo = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    WareInfo wareInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.GetComboBoxStrValue());

                    if (wareInfo != null)
                    {
                        int            oldQuantity = wareInfo.Amount;
                        double         oldPrice    = 0;
                        ItemDetailInfo info        = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo);

                        if (info != null)
                        {
                            oldPrice = info.Price;
                            double newPrice = ((Convert.ToInt32(detailInfo.Amount) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Amount) + oldQuantity);

                            detailInfo.Price = newPrice;
                        }
                    }

                    detailList.Add(detailInfo);
                }
            }

            ReportViewerDialog dlg = new ReportViewerDialog();

            dlg.DataSourceDict.Add("PurchaseHeaderInfo", new List <PurchaseHeaderInfo>()
            {
                headInfo
            });
            dlg.DataSourceDict.Add("PurchaseDetailInfo", detailList);
            dlg.ReportFilePath = "Report/WHC.WareHouseMis.PurchaseReport.rdlc";
            dlg.Parameters.Add("CompanyName", this.AppInfo.AppUnit);
            dlg.ShowDialog();
        }
コード例 #8
0
        private void SpecilaExport()
        {
            string           TakeOutBill = Path.Combine(Application.StartupPath, "TakeOutBill.xls");
            WorkbookDesigner designer    = new WorkbookDesigner();

            designer.Workbook = new Workbook(TakeOutBill);
            designer.SetDataSource("TakeOutDate", DateTime.Now.ToString("yyyy-MM-dd"));
            designer.SetDataSource("WareHouse", this.txtWareHouse.Text);
            designer.SetDataSource("Manager", this.txtCreator.Text);
            designer.SetDataSource("CostCenter", this.txtCostCenter.Text);
            //designer.SetDataSource("Dept", this.txtDept.Text);

            string    columns = "Start|int,ItemNo,ItemName,Specification,Unit,Price|decimal,Count|int";
            DataTable dt      = DataTableHelper.CreateTable(columns);

            dt.TableName = "Detail";
            DataRow row = null;

            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo info = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (info != null)
                {
                    row                  = dt.NewRow();
                    row["Start"]         = (i + 1);
                    row["ItemNo"]        = info.ItemNo;
                    row["ItemName"]      = info.ItemName;
                    row["Specification"] = info.Specification;
                    row["Unit"]          = info.Unit;
                    row["Price"]         = info.Price;
                    row["Count"]         = Math.Abs(info.Quantity);
                    dt.Rows.Add(row);
                }
            }
            designer.SetDataSource(dt);
            designer.Process();

            SpecialDirectories sp         = new SpecialDirectories();
            string             fileToSave = FileDialogHelper.SaveExcel(string.Format("出库单({0})", DateTime.Now.ToString("yyyy-MM-dd")), sp.Desktop);

            if (string.IsNullOrEmpty(fileToSave))
            {
                return;
            }

            if (File.Exists(fileToSave))
            {
                File.Delete(fileToSave);
            }
            designer.Workbook.Save(fileToSave, SaveFormat.Excel97To2003);
            Process.Start(fileToSave);
        }
コード例 #9
0
        private void btnModifyExpired_Click(object sender, EventArgs e)
        {
            if (this.lvwDetail.SelectedItems.Count == 0)
            {
                return;
            }

            PurchaseDetailInfo info = this.lvwDetail.SelectedItems[0].Tag as PurchaseDetailInfo;

            if (info != null)
            {
            }
        }
コード例 #10
0
        private void InsertOnItem(ItemDetailInfo itemDetailInfo)
        {
            int count = Convert.ToInt32(this.txtQuantity.Text);

            if (count <= 0)
            {
                MessageDxUtil.ShowTips("数量必须大于0");
                this.txtQuantity.Focus();
                return;
            }

            #region 构造入库信息
            PurchaseDetailInfo detailInfo = new PurchaseDetailInfo();
            detailInfo.Amount        = itemDetailInfo.Price * count;
            detailInfo.ItemName      = itemDetailInfo.ItemName;
            detailInfo.ItemNo        = itemDetailInfo.ItemNo;
            detailInfo.OperationType = "入库";
            detailInfo.ItemBigType   = itemDetailInfo.ItemBigType;
            detailInfo.ItemType      = itemDetailInfo.ItemType;
            detailInfo.MapNo         = itemDetailInfo.MapNo;
            detailInfo.Material      = itemDetailInfo.Material;
            detailInfo.Source        = itemDetailInfo.Source;
            detailInfo.Specification = itemDetailInfo.Specification;
            detailInfo.StoragePos    = itemDetailInfo.StoragePos;
            detailInfo.UsagePos      = itemDetailInfo.UsagePos;
            detailInfo.Price         = itemDetailInfo.Price;
            detailInfo.Quantity      = count;
            detailInfo.Unit          = itemDetailInfo.Unit;
            detailInfo.WareHouse     = itemDetailInfo.WareHouse;
            detailInfo.Dept          = itemDetailInfo.Dept;
            //detailInfo.PurchaseHead_ID =
            #endregion

            if (detailDict.ContainsKey(itemDetailInfo.ItemNo))
            {
                PurchaseDetailInfo tempInfo = detailDict[itemDetailInfo.ItemNo];
                tempInfo.Amount   += itemDetailInfo.Price * count;
                tempInfo.Quantity += count;
            }
            else
            {
                detailDict.Add(itemDetailInfo.ItemNo, detailInfo);
            }
        }
コード例 #11
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //消费退单
            if (this.lvwDetail.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem       item = this.lvwDetail.SelectedItems[0];
            PurchaseDetailInfo info = item.Tag as PurchaseDetailInfo;

            if (info != null)
            {
                if (detailDict.ContainsKey(info.ItemNo))
                {
                    detailDict.Remove(info.ItemNo);
                }
                BindData();
            }
        }
コード例 #12
0
        private void lvwDetail_DoubleClick(object sender, EventArgs e)
        {
            if (this.lvwDetail.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem item = this.lvwDetail.SelectedItems[0];

            if (item != null)
            {
                PurchaseDetailInfo info = item.Tag as PurchaseDetailInfo;

                FrmSetPurchaseQuantity dlg = new FrmSetPurchaseQuantity();
                dlg.txtItemNo.Text    = info.ItemNo;
                dlg.txtItemName.Text  = info.ItemName;
                dlg.txtQuantity.Text  = info.Quantity.ToString();
                dlg.txtPrice.Text     = info.Price.ToString("f2");
                dlg.txtPrice.ReadOnly = !IsPurchase;

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    item.SubItems[6].Text = dlg.txtQuantity.Text;
                    int     quntity = Convert.ToInt32(dlg.txtQuantity.Text);
                    decimal price   = Convert.ToDecimal(dlg.txtPrice.Text);
                    item.SubItems[7].Text = (price * quntity).ToString("C2");

                    //入库的时候,数量,单价可以修改,因此需要重新获取单价信息,作为标准单价
                    PurchaseDetailInfo tempInfo = detailDict[info.ItemNo];
                    tempInfo.Amount   = price * quntity;
                    tempInfo.Quantity = quntity;
                    tempInfo.Price    = price;

                    //重新设置Tag的信息
                    item.Tag = tempInfo;

                    BindData();
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// 装备单据数据
        /// </summary>
        /// <returns></returns>
        private DataTable PrepareBillData()
        {
            #region 准备数据
            string    columns = @"流水号,备注,供货商,操作员,库房名称,备件编号(pm码),备件名称,图号,规格型号,材质,备件属类,备件类别,单位,最新单价(元),入库数量,总价,入库日期,来源,库位,部门,使用位置";
            DataTable dt      = DataTableHelper.CreateTable(columns);
            DataRow   row     = null;
            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo info = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (info != null)
                {
                    row              = dt.NewRow();
                    row["流水号"]       = this.txtHandNo.Text;
                    row["备注"]        = this.txtNote.Text;
                    row["供货商"]       = this.txtManufacture.Text;
                    row["操作员"]       = this.txtCreator.Text;
                    row["入库日期"]      = this.txtCreateDate.DateTime.ToString();
                    row["库房名称"]      = info.WareHouse;
                    row["备件编号(pm码)"] = info.ItemNo;
                    row["备件名称"]      = info.ItemName;
                    row["图号"]        = info.MapNo;
                    row["规格型号"]      = info.Specification;
                    row["材质"]        = info.Material;
                    row["备件属类"]      = info.ItemBigType;
                    row["备件类别"]      = info.ItemType;
                    row["单位"]        = info.Unit;
                    row["最新单价(元)"]   = info.Price.ToString("C2");
                    row["入库数量"]      = info.Quantity.ToString();
                    row["总价"]        = info.Amount.ToString("C2");
                    row["来源"]        = info.Source;
                    row["库位"]        = info.StoragePos;
                    row["部门"]        = info.Dept;
                    row["使用位置"]      = info.UsagePos;
                    dt.Rows.Add(row);
                }
            }
            #endregion

            return(dt);
        }
コード例 #14
0
        private void btnPrintBill_Click(object sender, EventArgs e)
        {
            PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();

            headInfo.CreateDate    = txtCreateDate.DateTime;
            headInfo.Creator       = this.txtCreator.Text;
            headInfo.HandNo        = this.txtHandNo.Text;
            headInfo.Manufacture   = this.txtManufacture.Text;
            headInfo.Note          = this.txtNote.Text;
            headInfo.OperationType = "出库";
            headInfo.WareHouse     = this.txtWareHouse.Text;
            headInfo.CostCenter    = this.txtCostCenter.Text;
            headInfo.CreateYear    = DateTime.Now.Year;
            headInfo.CreateMonth   = DateTime.Now.Month;
            headInfo.PickingPeople = this.txtPickingPeople.Text;//领料人

            List <PurchaseDetailInfo> detailList = new List <PurchaseDetailInfo>();

            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    detailList.Add(detailInfo);
                }
            }

            //WHC.WareHouseMis.TakeOutReport.rdlc
            ReportViewerDialog dlg = new ReportViewerDialog();

            dlg.DataSourceDict.Add("PurchaseHeaderInfo", new List <PurchaseHeaderInfo>()
            {
                headInfo
            });
            dlg.DataSourceDict.Add("PurchaseDetailInfo", detailList);
            dlg.ReportFilePath = "Report/WHC.WareHouseMis.TakeOutReport.rdlc";

            dlg.Parameters.Add("CompanyName", Portal.gc.gAppUnit);
            dlg.ShowDialog();
        }
コード例 #15
0
        private void AddStockQuantity(PurchaseDetailInfo detailInfo)
        {
            //先更新库存的价格为加权价格
            StockInfo stockInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.Text);

            if (stockInfo != null)
            {
                int            oldQuantity = stockInfo.StockQuantity;
                decimal        oldPrice    = 0M;
                ItemDetailInfo info        = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo);

                if (info != null)
                {
                    oldPrice = info.Price;
                    decimal newPrice = ((Convert.ToInt32(detailInfo.Quantity) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Quantity) + oldQuantity);

                    info.Price = newPrice;
                    BLLFactory <ItemDetail> .Instance.Update(info, info.ID.ToString());
                }
            }

            BLLFactory <Stock> .Instance.AddStockQuantiy(detailInfo.ItemNo, detailInfo.ItemName,
                                                         Convert.ToInt32(detailInfo.Quantity), this.txtWareHouse.Text);
        }
コード例 #16
0
ファイル: FrmPurchase.cs プロジェクト: 15831944/winform-1
        private void AddStockQuantity(PurchaseDetailInfo detailInfo)
        {
            //先更新库存的价格为加权价格
            WareInfo wareInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.GetComboBoxStrValue());

            if (wareInfo != null)
            {
                int            oldQuantity = wareInfo.Amount;
                double         oldPrice    = 0;
                ItemDetailInfo info        = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo);

                if (info != null)
                {
                    oldPrice = info.Price;
                    double newPrice = ((Convert.ToInt32(detailInfo.Amount) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Amount) + oldQuantity);

                    info.Price = (double)newPrice;
                    BLLFactory <ItemDetail> .Instance.Update(info, info.Id);
                }
            }

            BLLFactory <Stock> .Instance.AddStockQuantiy(detailInfo.ItemNo, detailInfo.Name,
                                                         Convert.ToInt32(detailInfo.Amount), this.txtWareHouse.GetComboBoxStrValue().ToInt32());
        }
コード例 #17
0
        private void btnExportBill_Click(object sender, EventArgs e)
        {
            #region 准备数据
            string    columns = @"流水号,备注,供货商,操作员,库房名称,备件编号(pm码),备件名称,图号,规格型号,材质,备件属类,备件类别,单位,最新单价(元),出库数量,总价,出库日期,来源,库位,部门,使用位置";
            DataTable dt      = DataTableHelper.CreateTable(columns);
            DataRow   row     = null;
            for (int i = 0; i < this.lvwDetail.gridView1.RowCount; i++)
            {
                PurchaseDetailInfo info = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo;
                if (info != null)
                {
                    row = dt.NewRow();

                    /*row["流水号"] = this.txtHandNo.Text;
                     * row["备注"] = this.txtNote.Text;
                     * row["供货商"] = this.txtPickingPeople.Text;
                     * row["操作员"] = this.txtCreator.Text;
                     * row["出库日期"] = this.txtCreateDate.DateTime.ToString();
                     * row["库房名称"] = info.WareHouse;
                     * row["备件编号(pm码)"] = info.ItemNo;
                     * row["备件名称"] = info.ItemName;
                     * row["图号"] = info.MapNo;
                     * row["规格型号"] = info.Specification;
                     * row["材质"] = info.Material;
                     * row["备件属类"] = info.ItemBigType;
                     * row["备件类别"] = info.ItemType;
                     * row["单位"] = info.Unit;
                     * row["最新单价(元)"] = info.Price.ToString("C2");
                     * row["出库数量"] = info.Quantity.ToString();
                     * row["总价"] = info.Amount.ToString("C2");
                     * row["来源"] = info.Source;
                     * row["库位"] = info.StoragePos;
                     * row["部门"] = info.Dept;
                     * row["使用位置"] = info.UsagePos;*/
                    dt.Rows.Add(row);
                }
            }
            #endregion

            #region 导出数据
            try
            {
                SpecialDirectories sp       = new SpecialDirectories();
                string             fileName = FileDialogHelper.SaveExcel(string.Format("出库单({0})", DateTimeHelper.GetServerDate()), sp.Desktop);
                if (string.IsNullOrEmpty(fileName))
                {
                    return;
                }
                string outError = "";
                AsposeExcelTools.DataTableToExcel2(dt, fileName, out outError);
                if (!string.IsNullOrEmpty(outError))
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, outError, typeof(FrmPurchase));
                    MessageDxUtil.ShowError(outError);
                }
                else
                {
                    Process.Start(fileName);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmPurchase));
                MessageDxUtil.ShowError(ex.Message);
            }
            #endregion
        }
コード例 #18
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 验证输入

            //检查是否可以入库出库
            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtWareHouse.Text, detailInfo.ItemNo);

                    if (!isInit)
                    {
                        MessageDxUtil.ShowTips(string.Format("备件项目【{0}】在库房【{1}】还没有期初建账,请先在备件信息管理中进行期初建账。", detailInfo.ItemNo, this.txtWareHouse.Text));
                        return;
                    }
                }
            }

            if (this.txtHandNo.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("货单编号不能为空");
                this.txtHandNo.Focus();
                return;
            }
            else if (this.txtManufacture.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择供应商");
                this.txtManufacture.Focus();
                return;
            }
            else if (this.txtCostCenter.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择成本中心");
                this.txtCostCenter.Focus();
                return;
            }
            else if (this.txtWareHouse.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择仓库");
                this.txtWareHouse.Focus();
                return;
            }
            else if (this.lvwDetail.Items.Count == 0)
            {
                MessageDxUtil.ShowTips("请添加商品");
                return;
            }
            else if (this.txtCreator.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请选择经手人");
                this.txtCreator.Focus();
                return;
            }
            else if (this.txtPickingPeople.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请输入领料人");
                this.txtPickingPeople.Focus();
                return;
            }
            #endregion

            try
            {
                PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();
                headInfo.CreateDate    = txtCreateDate.DateTime;
                headInfo.Creator       = this.txtCreator.Text;
                headInfo.HandNo        = this.txtHandNo.Text;
                headInfo.Manufacture   = this.txtManufacture.Text;
                headInfo.Note          = this.txtNote.Text;
                headInfo.OperationType = "出库";
                headInfo.WareHouse     = this.txtWareHouse.Text;
                headInfo.CostCenter    = this.txtCostCenter.Text;
                headInfo.CreateYear    = DateTime.Now.Year;
                headInfo.CreateMonth   = DateTime.Now.Month;
                //领料人
                headInfo.PickingPeople = this.txtPickingPeople.Text;

                int headId = BLLFactory <PurchaseHeader> .Instance.Insert2(headInfo);

                if (headId > 0)
                {
                    for (int i = 0; i < this.lvwDetail.Items.Count; i++)
                    {
                        PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                        if (detailInfo != null)
                        {
                            detailInfo.PurchaseHead_ID = headId;
                            BLLFactory <PurchaseDetail> .Instance.Insert(detailInfo);

                            AddStockQuantity(detailInfo);//增加库存
                        }
                    }

                    MessageDxUtil.ShowTips("保存成功");
                    ClearContent();

                    //低库存预警检查
                    bool lowWarning = BLLFactory <Stock> .Instance.CheckStockLowWarning(this.txtWareHouse.Text);

                    if (lowWarning)
                    {
                        string message = string.Format("{0} 库存已经处于低库存预警状态\r\n请及时补充库存", this.txtWareHouse.Text);
                        Portal.gc.Notify(string.Format("{0} 低库存预警", this.txtWareHouse.Text), message);
                    }
                }
                else
                {
                    MessageDxUtil.ShowError("保存失败");
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
        }
コード例 #19
0
        private void btnExportBill_Click(object sender, EventArgs e)
        {
            #region 准备数据
            string    columns = @"流水号,备注,供货商,操作员,库房名称,备件编号(pm码),备件名称,图号,规格型号,材质,备件属类,备件类别,单位,最新单价(元),入库数量,总价,入库日期,来源,库位,部门,使用位置";
            DataTable dt      = DataTableHelper.CreateTable(columns);
            DataRow   row     = null;
            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo info = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (info != null)
                {
                    row              = dt.NewRow();
                    row["流水号"]       = this.txtHandNo.Text;
                    row["备注"]        = this.txtNote.Text;
                    row["供货商"]       = this.txtManufacture.Text;
                    row["操作员"]       = this.txtCreator.Text;
                    row["入库日期"]      = this.txtCreateDate.DateTime.ToString();
                    row["库房名称"]      = info.WareHouse;
                    row["备件编号(pm码)"] = info.ItemNo;
                    row["备件名称"]      = info.ItemName;
                    row["图号"]        = info.MapNo;
                    row["规格型号"]      = info.Specification;
                    row["材质"]        = info.Material;
                    row["备件属类"]      = info.ItemBigType;
                    row["备件类别"]      = info.ItemType;
                    row["单位"]        = info.Unit;
                    row["最新单价(元)"]   = info.Price.ToString("C2");
                    row["入库数量"]      = info.Quantity.ToString();
                    row["总价"]        = info.Amount.ToString("C2");
                    row["来源"]        = info.Source;
                    row["库位"]        = info.StoragePos;
                    row["部门"]        = info.Dept;
                    row["使用位置"]      = info.UsagePos;
                    dt.Rows.Add(row);
                }
            }
            #endregion

            #region 导出数据
            try
            {
                SpecialDirectories sp       = new SpecialDirectories();
                string             fileName = FileDialogHelper.SaveExcel(string.Format("入库单({0})", DateTime.Now.ToString("yyyy-MM-dd")), sp.Desktop);
                if (string.IsNullOrEmpty(fileName))
                {
                    return;
                }
                string outError = "";
                AsposeExcelTools.DataTableToExcel2(dt, fileName, out outError);
                if (!string.IsNullOrEmpty(outError))
                {
                    MessageDxUtil.ShowError(outError);
                    LogTextHelper.Error(outError);
                }
                else
                {
                    Process.Start(fileName);
                }
            }
            catch (Exception ex)
            {
                MessageDxUtil.ShowError(ex.Message);
                LogTextHelper.Error(ex);
            }
            #endregion
        }
コード例 #20
0
ファイル: FrmPurchase.cs プロジェクト: 15831944/winform-1
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 验证输入

            //检查是否可以入库出库
            for (int i = 0; i < this.lvwDetail.gridView1.DataRowCount; i++)
            {
                PurchaseDetailInfo detailInfo = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtWareHouse.GetComboBoxStrValue(), detailInfo.ItemNo);

                    if (!isInit)
                    {
                        if (MessageDxUtil.ShowYesNoAndTips(string.Format("备件项目【{0}】在库房【{1}】还没有期初建账,您是否要进行期初建账,初始化库存为0?\r\n按【是】初始化库房并继续,按【否】退出。",
                                                                         detailInfo.ItemNo, this.txtWareHouse.Text)) == DialogResult.No)
                        {
                            return;
                        }
                        else
                        {
                            ItemDetailInfo itemInfo = new ItemDetailInfo();
                            itemInfo.ItemNo      = detailInfo.ItemNo;
                            itemInfo.Name        = detailInfo.Name;
                            itemInfo.ItemBigtype = detailInfo.ItemBigtype;
                            itemInfo.ItemType    = detailInfo.ItemType;

                            BLLFactory <Stock> .Instance.InitStockQuantity(itemInfo, 0, this.txtWareHouse.GetComboBoxStrValue().ToInt32());
                        }
                    }
                }
            }

            if (this.txtHandNo.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("货单编号不能为空");
                this.txtHandNo.Focus();
                return;
            }
            else if (this.txtManufacture.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择供应商");
                this.txtManufacture.Focus();
                return;
            }
            else if (this.txtWareHouse.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择仓库");
                this.txtWareHouse.Focus();
                return;
            }
            else if (this.lvwDetail.gridView1.RowCount == 0)
            {
                MessageDxUtil.ShowTips("请添加商品");
                return;
            }
            else if (this.txtCreator.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请选择经手人");
                this.txtCreator.Focus();
                return;
            }
            #endregion

            try
            {
                PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();
                headInfo.CreatorTime   = txtCreateDate.DateTime;
                headInfo.CreatorId     = this.txtCreator.Text.ToInt32();
                headInfo.OrderNo       = this.txtHandNo.Text;
                headInfo.Manufacture   = this.txtManufacture.GetComboBoxStrValue();
                headInfo.Remark        = this.txtNote.Text;
                headInfo.OperationType = (short)OperationType.新增;// 入库
                headInfo.WareHouseId   = this.txtWareHouse.GetComboBoxStrValue().ToInt32();
                headInfo.CreatorYear   = DateTimeHelper.GetServerDateTime2().Year;
                headInfo.CreatorMonth  = (short)DateTimeHelper.GetServerDateTime2().Month;

                int headId = BLLFactory <PurchaseHeader> .Instance.Insert2(headInfo);

                if (headId > 0)
                {
                    for (int i = 0; i < this.lvwDetail.gridView1.DataRowCount; i++)
                    {
                        PurchaseDetailInfo detailInfo = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo;
                        if (detailInfo != null)
                        {
                            detailInfo.PurchaseHeadId = headId;
                            BLLFactory <PurchaseDetail> .Instance.Insert(detailInfo);

                            AddStockQuantity(detailInfo);//增加库存
                        }
                    }

                    MessageDxUtil.ShowTips("保存成功");
                    ClearContent();

                    //超库存预警检查
                    bool highWarning = BLLFactory <Stock> .Instance.CheckStockHighWarning(this.txtWareHouse.GetComboBoxStrValue());

                    if (highWarning)
                    {
                        string message = string.Format("{0} 库存量已经高过超预警库存量\r\n请注意减少库存积压", this.txtWareHouse.Text);
                        Portal.gc.Notify(string.Format("{0} 超库存预警", this.txtWareHouse.Text), message);
                    }
                }
                else
                {
                    MessageDxUtil.ShowError("保存失败");
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmPurchase));
                MessageDxUtil.ShowError(ex.Message);
            }
        }
コード例 #21
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 验证输入

            //检查是否可以入库出库
            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtWareHouse.Text, detailInfo.ItemNo);

                    if (!isInit)
                    {
                        if (MessageDxUtil.ShowYesNoAndTips(string.Format("备件项目【{0}】在库房【{1}】还没有期初建账,您是否要进行期初建账,初始化库存为0?\r\n按【是】初始化库房并继续,按【否】退出。",
                                                                         detailInfo.ItemNo, this.txtWareHouse.Text)) == DialogResult.No)
                        {
                            return;
                        }
                        else
                        {
                            ItemDetailInfo itemInfo = new ItemDetailInfo();
                            itemInfo.ItemNo      = detailInfo.ItemNo;
                            itemInfo.ItemName    = detailInfo.ItemName;
                            itemInfo.ItemBigType = detailInfo.ItemBigType;
                            itemInfo.ItemType    = detailInfo.ItemType;

                            BLLFactory <Stock> .Instance.InitStockQuantity(itemInfo, 0, this.txtWareHouse.Text);
                        }
                    }
                }
            }

            if (this.txtHandNo.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("货单编号不能为空");
                this.txtHandNo.Focus();
                return;
            }
            else if (this.txtManufacture.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择供应商");
                this.txtManufacture.Focus();
                return;
            }
            else if (this.txtWareHouse.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择仓库");
                this.txtWareHouse.Focus();
                return;
            }
            else if (this.lvwDetail.Items.Count == 0)
            {
                MessageDxUtil.ShowTips("请添加商品");
                return;
            }
            else if (this.txtCreator.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请选择经手人");
                this.txtCreator.Focus();
                return;
            }
            #endregion

            try
            {
                PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();
                headInfo.CreateDate    = txtCreateDate.DateTime;
                headInfo.Creator       = this.txtCreator.Text;
                headInfo.HandNo        = this.txtHandNo.Text;
                headInfo.Manufacture   = this.txtManufacture.Text;
                headInfo.Note          = this.txtNote.Text;
                headInfo.OperationType = "入库";
                headInfo.WareHouse     = this.txtWareHouse.Text;
                headInfo.CreateYear    = DateTime.Now.Year;
                headInfo.CreateMonth   = DateTime.Now.Month;

                int headId = BLLFactory <PurchaseHeader> .Instance.Insert2(headInfo);

                if (headId > 0)
                {
                    for (int i = 0; i < this.lvwDetail.Items.Count; i++)
                    {
                        PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                        if (detailInfo != null)
                        {
                            detailInfo.PurchaseHead_ID = headId;
                            BLLFactory <PurchaseDetail> .Instance.Insert(detailInfo);

                            AddStockQuantity(detailInfo);//增加库存
                        }
                    }

                    MessageDxUtil.ShowTips("保存成功");
                    ClearContent();

                    //超库存预警检查
                    bool highWarning = BLLFactory <Stock> .Instance.CheckStockHighWarning(this.txtWareHouse.Text);

                    if (highWarning)
                    {
                        string message = string.Format("{0} 库存量已经高过超预警库存量\r\n请注意减少库存积压", this.txtWareHouse.Text);
                        WareHouseHelper.Notify(string.Format("{0} 超库存预警", this.txtWareHouse.Text), message);
                    }
                }
                else
                {
                    MessageDxUtil.ShowError("保存失败");
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
        }