增加销售订单

Beta
凯 王 2021-05-31 18:22:37 +08:00
parent 7a2f5a016f
commit 699b5a929e
20 changed files with 3726 additions and 64 deletions

View File

@ -327,6 +327,38 @@ namespace WinformGeneralDeveloperFrame.Commons
}
return dt;
}
public static DataTable ToDataTable2<T>(this IEnumerable<T> varlist)
{
DataTable dtReturn = new DataTable();
// column names
PropertyInfo[] oProps = null;
// Could add a check to verify that there is an element 0
foreach (T rec in varlist)
{
if (oProps == null)
{
oProps = ((Type)rec.GetType()).GetProperties();
foreach (PropertyInfo pi in oProps)
{
Type colType = pi.PropertyType; if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition() == typeof(Nullable<>)))
{
colType = colType.GetGenericArguments()[0];
}
dtReturn.Columns.Add(new DataColumn(pi.Name, colType));
}
}
DataRow dr = dtReturn.NewRow(); foreach (PropertyInfo pi in oProps)
{
dr[pi.Name] = pi.GetValue(rec, null) == null ? DBNull.Value : pi.GetValue(rec, null);
}
dtReturn.Rows.Add(dr);
}
return (dtReturn);
}
public delegate object[] CreateRowDelegate<T>(T t);
/// <summary>
/// 获取datatable数据
/// </summary>

View File

@ -37,6 +37,11 @@ namespace MES
public virtual DbSet<quotationdetailInfo> quotationdetailInfo { get; set; }
public virtual DbSet<saleInfo> saleInfo { get; set; }
public virtual DbSet<saledetailInfo> saledetailInfo { get; set; }
}
}

View File

@ -14,8 +14,8 @@ namespace MES.Entity
///id
[ModelBindControl("txtid")]
public int id{set;get;}
///客户名称
[ModelBindControl("txtcustomername")]
///客户名称phonenumber
[ModelBindControl("txtcustomername")]
public string customername{set;get;}
///客户类别
[ModelBindControl("txtcustomertype")]
@ -25,9 +25,13 @@ namespace MES.Entity
public int contactuser{set;get;}
///客户地址
[ModelBindControl("txtaddress")]
public string address{set;get;}
///期初应收款
[ModelBindControl("txtstartreceipt")]
///电话phonenumber
[ModelBindControl("txtphonenumber")]
public string phonenumber { set; get; }
///期初应收款
[ModelBindControl("txtstartreceipt")]
public decimal startreceipt{set;get;}
///客户编号
[ModelBindControl("txtcustomercode")]

View File

@ -19,7 +19,7 @@ namespace MES.Entity
public int customerid{set;get;}
///报价日期
[ModelBindControl("txtquotationdate")]
public DateTime? quotationdate{set;get;}=DateTime.Now;
public DateTime quotationdate{set;get;}=DateTime.Now;
///客户编码
[ModelBindControl("txtcustomercode")]
public string customercode{set;get;}

View File

@ -16,8 +16,11 @@ namespace MES.Entity
public int id{set;get;}
///产品名称
[ModelBindControl("txtproductid")]
public int productid{set;get;}
///规格型号
public string productname { set; get; }
///规格型号
[ModelBindControl("txtspec")]
public string spec{set;get;}
///报价数量

View File

@ -0,0 +1,58 @@
using WinformGeneralDeveloperFrame.Commons;
namespace MES.Entity
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
[Table("sale")]
public partial class saleInfo
{
///id
[ModelBindControl("txtid")]
public int id{set;get;}
///销售单号
[ModelBindControl("txtsaleordercode")]
public string saleordercode{set;get;}
///订单日期
[ModelBindControl("txtorderdate")]
public DateTime orderdate{set;get;}=DateTime.Now;
///客户
[ModelBindControl("txtcustomerid")]
public int customerid{set;get;}
///客户编号
[ModelBindControl("txtcustomercode")]
public string customercode{set;get;}
///客户类型
[ModelBindControl("txtcustomertype")]
public int customertype{set;get;}
///客户单号
[ModelBindControl("txtcustomerordercode")]
public string customerordercode{set;get;}
///联系人
[ModelBindControl("txtcontactuser")]
public int contactuser{set;get;}
///联系电话
[ModelBindControl("txtcontactphone")]
public string contactphone{set;get;}
///送货地址
[ModelBindControl("txtdeliveraddress")]
public string deliveraddress{set;get;}
///业务员
[ModelBindControl("txtsalesman")]
public int salesman{set;get;}
///完货日期
[ModelBindControl("txtfinishdate")]
public DateTime finishdate{set;get;}=DateTime.Now;
///制单人
[ModelBindControl("txtcreatorId")]
public int creatorId { set;get;}
///备注
[ModelBindControl("txtremark")]
public string remark{set;get;}
}
}

View File

@ -0,0 +1,85 @@
using WinformGeneralDeveloperFrame.Commons;
namespace MES.Entity
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
[Table("saledetail")]
public partial class saledetailInfo
{
///id
[ModelBindControl("txtid")]
public int id{set;get;}
///产品
[ModelBindControl("txtproductid")]
public int productid{set;get;}
///规格型号
[ModelBindControl("txtproductspec")]
public string productspec{set;get;}
///数量
[ModelBindControl("txtsalenumber")]
public decimal salenumber{set;get;}
///计量单位
[ModelBindControl("txtunit")]
public int unit{set;get;}
///单价
[ModelBindControl("txtunitprice")]
public decimal unitprice{set;get;}
///金额
[ModelBindControl("txtmoney")]
public decimal money{set;get;}
///交货日期
[ModelBindControl("txtdeliverdate")]
public DateTime deliverdate{set;get;}=DateTime.Now;
///仓库
[ModelBindControl("txtwarehouse")]
public int warehouse{set;get;}
///已排产量
[ModelBindControl("txtreadynumber")]
public decimal readynumber{set;get;}
///待排产量
[ModelBindControl("txtnoreadynumber")]
public decimal noreadynumber{set;get;}
///已完工量
[ModelBindControl("txtfinishnumber")]
public decimal finishnumber{set;get;}
///已出货量
[ModelBindControl("txtoutnumber")]
public decimal outnumber{set;get;}
///退货量
[ModelBindControl("txtreturnnumber")]
public decimal returnnumber{set;get;}
///未交货数量
[ModelBindControl("txtnodelivernumber")]
public decimal nodelivernumber{set;get;}
///实际交货数量
[ModelBindControl("txtdelivernumber")]
public decimal delivernumber{set;get;}
///已结算数量
[ModelBindControl("txtclosenumber")]
public decimal closenumber{set;get;}
///未结算数量
[ModelBindControl("txtnoclosenumber")]
public decimal noclosenumber{set;get;}
///物料成本
[ModelBindControl("txtmaterialcost")]
public decimal materialcost{set;get;}
///实际物料成本
[ModelBindControl("txtrealmaterialcost")]
public decimal realmaterialcost{set;get;}
///产品编号
[ModelBindControl("txtproductcode")]
public string productcode{set;get;}
///销售主表
[ModelBindControl("txtsaleid")]
public int saleid{set;get;}
///销售单号
[ModelBindControl("txtsalecode")]
public string salecode{set;get;}
}
}

View File

@ -77,6 +77,9 @@ namespace MES.Form
this.layoutControlItem8 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem10 = new DevExpress.XtraLayout.LayoutControlItem();
this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
this.gridColumn12 = new DevExpress.XtraGrid.Columns.GridColumn();
this.txtphonenumber = new DevExpress.XtraEditors.TextEdit();
this.layoutControlItem12 = new DevExpress.XtraLayout.LayoutControlItem();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemtxtcustomertype)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemtxtcontactuser)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xtraTabControl1)).BeginInit();
@ -113,6 +116,8 @@ namespace MES.Form
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.txtphonenumber.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem12)).BeginInit();
this.SuspendLayout();
//
// gridColumn1
@ -274,7 +279,8 @@ namespace MES.Form
this.gridColumn8,
this.gridColumn9,
this.gridColumn10,
this.gridColumn11});
this.gridColumn11,
this.gridColumn12});
this.grdListView.GridControl = this.grdList;
this.grdListView.Name = "grdListView";
this.grdListView.OptionsBehavior.Editable = false;
@ -298,6 +304,7 @@ namespace MES.Form
//
// layoutControl1
//
this.layoutControl1.Controls.Add(this.txtphonenumber);
this.layoutControl1.Controls.Add(this.txtid);
this.layoutControl1.Controls.Add(this.txtcustomername);
this.layoutControl1.Controls.Add(this.txtcustomertype);
@ -373,7 +380,7 @@ namespace MES.Form
//
// txtstartreceipt
//
this.txtstartreceipt.Location = new System.Drawing.Point(502, 84);
this.txtstartreceipt.Location = new System.Drawing.Point(75, 108);
this.txtstartreceipt.Name = "txtstartreceipt";
this.txtstartreceipt.Size = new System.Drawing.Size(360, 20);
this.txtstartreceipt.StyleController = this.layoutControl1;
@ -389,15 +396,15 @@ namespace MES.Form
//
// txttotalreceivables
//
this.txttotalreceivables.Location = new System.Drawing.Point(75, 132);
this.txttotalreceivables.Location = new System.Drawing.Point(502, 108);
this.txttotalreceivables.Name = "txttotalreceivables";
this.txttotalreceivables.Size = new System.Drawing.Size(787, 20);
this.txttotalreceivables.Size = new System.Drawing.Size(360, 20);
this.txttotalreceivables.StyleController = this.layoutControl1;
this.txttotalreceivables.TabIndex = 8;
//
// txttotalamountsettled
//
this.txttotalamountsettled.Location = new System.Drawing.Point(75, 108);
this.txttotalamountsettled.Location = new System.Drawing.Point(75, 132);
this.txttotalamountsettled.Name = "txttotalamountsettled";
this.txttotalamountsettled.Size = new System.Drawing.Size(360, 20);
this.txttotalamountsettled.StyleController = this.layoutControl1;
@ -405,7 +412,7 @@ namespace MES.Form
//
// txttotaloutstandingamount
//
this.txttotaloutstandingamount.Location = new System.Drawing.Point(502, 108);
this.txttotaloutstandingamount.Location = new System.Drawing.Point(502, 132);
this.txttotaloutstandingamount.Name = "txttotaloutstandingamount";
this.txttotaloutstandingamount.Size = new System.Drawing.Size(360, 20);
this.txttotaloutstandingamount.StyleController = this.layoutControl1;
@ -431,11 +438,12 @@ namespace MES.Form
this.layoutControlItem11,
this.layoutControlItem3,
this.layoutControlItem5,
this.layoutControlItem7,
this.layoutControlItem9,
this.layoutControlItem8,
this.layoutControlItem10,
this.emptySpaceItem1});
this.emptySpaceItem1,
this.layoutControlItem7,
this.layoutControlItem8,
this.layoutControlItem12});
this.layoutControlGroup1.Name = "layoutControlGroup1";
this.layoutControlGroup1.Size = new System.Drawing.Size(874, 528);
this.layoutControlGroup1.TextVisible = false;
@ -474,7 +482,7 @@ namespace MES.Form
//
this.layoutControlItem6.Control = this.txtstartreceipt;
this.layoutControlItem6.CustomizationFormText = "期初应收款";
this.layoutControlItem6.Location = new System.Drawing.Point(427, 72);
this.layoutControlItem6.Location = new System.Drawing.Point(0, 96);
this.layoutControlItem6.Name = "layoutControlItem6";
this.layoutControlItem6.Size = new System.Drawing.Size(427, 24);
this.layoutControlItem6.Text = "期初应收款";
@ -524,7 +532,7 @@ namespace MES.Form
//
this.layoutControlItem9.Control = this.txttotalamountsettled;
this.layoutControlItem9.CustomizationFormText = "已结款总额";
this.layoutControlItem9.Location = new System.Drawing.Point(0, 96);
this.layoutControlItem9.Location = new System.Drawing.Point(0, 120);
this.layoutControlItem9.Name = "layoutControlItem9";
this.layoutControlItem9.Size = new System.Drawing.Size(427, 24);
this.layoutControlItem9.Text = "已结款总额";
@ -534,9 +542,9 @@ namespace MES.Form
//
this.layoutControlItem8.Control = this.txttotalreceivables;
this.layoutControlItem8.CustomizationFormText = "应收款总额";
this.layoutControlItem8.Location = new System.Drawing.Point(0, 120);
this.layoutControlItem8.Location = new System.Drawing.Point(427, 96);
this.layoutControlItem8.Name = "layoutControlItem8";
this.layoutControlItem8.Size = new System.Drawing.Size(854, 24);
this.layoutControlItem8.Size = new System.Drawing.Size(427, 24);
this.layoutControlItem8.Text = "应收款总额";
this.layoutControlItem8.TextSize = new System.Drawing.Size(60, 14);
//
@ -544,7 +552,7 @@ namespace MES.Form
//
this.layoutControlItem10.Control = this.txttotaloutstandingamount;
this.layoutControlItem10.CustomizationFormText = "未结款总额";
this.layoutControlItem10.Location = new System.Drawing.Point(427, 96);
this.layoutControlItem10.Location = new System.Drawing.Point(427, 120);
this.layoutControlItem10.Name = "layoutControlItem10";
this.layoutControlItem10.Size = new System.Drawing.Size(427, 24);
this.layoutControlItem10.Text = "未结款总额";
@ -558,6 +566,32 @@ namespace MES.Form
this.emptySpaceItem1.Size = new System.Drawing.Size(854, 340);
this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
//
// gridColumn12
//
this.gridColumn12.Caption = "联系方式";
this.gridColumn12.FieldName = "phonenumber";
this.gridColumn12.Name = "gridColumn12";
this.gridColumn12.Visible = true;
this.gridColumn12.VisibleIndex = 10;
//
// txtphonenumber
//
this.txtphonenumber.Location = new System.Drawing.Point(502, 84);
this.txtphonenumber.Name = "txtphonenumber";
this.txtphonenumber.Size = new System.Drawing.Size(360, 20);
this.txtphonenumber.StyleController = this.layoutControl1;
this.txtphonenumber.TabIndex = 12;
//
// layoutControlItem12
//
this.layoutControlItem12.Control = this.txtphonenumber;
this.layoutControlItem12.CustomizationFormText = "联系方式";
this.layoutControlItem12.Location = new System.Drawing.Point(427, 72);
this.layoutControlItem12.Name = "layoutControlItem12";
this.layoutControlItem12.Size = new System.Drawing.Size(427, 24);
this.layoutControlItem12.Text = "联系方式";
this.layoutControlItem12.TextSize = new System.Drawing.Size(60, 14);
//
// Frmcustomer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
@ -604,6 +638,8 @@ namespace MES.Form
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtphonenumber.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem12)).EndInit();
this.ResumeLayout(false);
}
@ -667,5 +703,8 @@ namespace MES.Form
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem10;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem11;
private EmptySpaceItem emptySpaceItem1;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn12;
private TextEdit txtphonenumber;
private LayoutControlItem layoutControlItem12;
}
}

View File

@ -43,10 +43,15 @@ namespace MES.Form
gridView1.GetFocusedDataRow()["unit"] = product.unit;
gridView1.GetFocusedDataRow()["stockid"] = product.warehouse;
gridView1.GetFocusedDataRow()["productcode"] = product.productcode;
gridView1.GetFocusedDataRow()["productname"] = product.productname;
}
}
public override void InitFormFunction()
{
gridView1.BestFitColumns();
}
/// <summary>
/// 数据源初始化
/// </summary>
@ -152,8 +157,8 @@ namespace MES.Form
/// <returns></returns>
public override bool SaveFunction()
{
string code = "KHBJ" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour +
DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond;
string code = "KH" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour +
DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond.ToString("D3");
DataTable dt=gridControl1.DataSource as DataTable;
try
{
@ -172,7 +177,8 @@ namespace MES.Form
info.quotationcode = code;
db.quotationInfo.Add(info);
db.SaveChanges();
txtid.Text = info.id.ToString();
txtquotationcode.Text = code;
if (dt != null)
{
List<quotationdetailInfo> detaiListAdd =
@ -247,6 +253,7 @@ namespace MES.Form
db.Database.ExecuteSqlCommand($"delete from quotationdetail where quotationid={info.id}");
db.SaveChanges();
}
gridControl1.DataSource = null;
}
catch (Exception ex)
{
@ -300,6 +307,7 @@ namespace MES.Form
txtcustomertype.EditValue = customer.customertype;
txtcustomeruser.EditValue = customer.contactuser;
txtdeliveraddress.Text = customer.address;
}
}
}
@ -313,6 +321,7 @@ namespace MES.Form
using (var db=new MESDB())
{
gridControl1.DataSource = db.quotationdetailInfo.Where(p => p.quotationid == info.id).ToList().ToDataTable();
gridView1.BestFitColumns();
}
}
}
@ -331,6 +340,7 @@ namespace MES.Form
if (string.IsNullOrEmpty(gridView1.GetFocusedDataRow()["productid"].ToString()))
{
"请选择产品".ShowTips();
return;
}
if (!string.IsNullOrEmpty(gridView1.GetFocusedDataRow()["unitprice"].ToString()) &&
@ -341,6 +351,7 @@ namespace MES.Form
gridView1.GetFocusedDataRow()["number"].ToDecimal(0));
;
}
gridView1.BestFitColumns();
}
}
}

View File

@ -61,7 +61,7 @@ namespace MES.Form
this.toolStripMenuItemDel = new System.Windows.Forms.ToolStripMenuItem();
this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
this.gridColumn11 = new DevExpress.XtraGrid.Columns.GridColumn();
this.gridColumn12 = new DevExpress.XtraGrid.Columns.GridColumn();
this.productid = new DevExpress.XtraGrid.Columns.GridColumn();
this.repositoryItemtxtproductid = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit();
this.gridColumn13 = new DevExpress.XtraGrid.Columns.GridColumn();
this.gridColumn14 = new DevExpress.XtraGrid.Columns.GridColumn();
@ -97,6 +97,7 @@ namespace MES.Form
this.layoutControlItem8 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem9 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem11 = new DevExpress.XtraLayout.LayoutControlItem();
this.gridColumn12 = new DevExpress.XtraGrid.Columns.GridColumn();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemtxtcustomerid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemtxtcustomertype)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemtxtcustomeruser)).BeginInit();
@ -395,8 +396,9 @@ namespace MES.Form
// gridView1
//
this.gridView1.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
this.gridColumn11,
this.gridColumn12,
this.gridColumn11,
this.productid,
this.gridColumn13,
this.gridColumn14,
this.gridColumn15,
@ -419,15 +421,15 @@ namespace MES.Form
this.gridColumn11.FieldName = "id";
this.gridColumn11.Name = "gridColumn11";
//
// gridColumn12
// productid
//
this.gridColumn12.Caption = "产品名称";
this.gridColumn12.ColumnEdit = this.repositoryItemtxtproductid;
this.gridColumn12.FieldName = "productid";
this.gridColumn12.Name = "gridColumn12";
this.gridColumn12.Visible = true;
this.gridColumn12.VisibleIndex = 0;
this.gridColumn12.Width = 201;
this.productid.Caption = "产品名称";
this.productid.ColumnEdit = this.repositoryItemtxtproductid;
this.productid.FieldName = "productid";
this.productid.Name = "productid";
this.productid.Visible = true;
this.productid.VisibleIndex = 0;
this.productid.Width = 201;
//
// repositoryItemtxtproductid
//
@ -492,7 +494,7 @@ namespace MES.Form
this.gridColumn17.FieldName = "money";
this.gridColumn17.Name = "gridColumn17";
this.gridColumn17.Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] {
new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum, "money", "SUM={0:0.##}")});
new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum, "money", "总金额={0:0.##}")});
this.gridColumn17.Visible = true;
this.gridColumn17.VisibleIndex = 5;
this.gridColumn17.Width = 201;
@ -797,6 +799,12 @@ namespace MES.Form
this.layoutControlItem11.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem11.TextVisible = false;
//
// gridColumn12
//
this.gridColumn12.Caption = "gridColumn12";
this.gridColumn12.FieldName = "productname";
this.gridColumn12.Name = "gridColumn12";
//
// Frmquotation
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
@ -916,7 +924,7 @@ namespace MES.Form
private DevExpress.XtraGrid.GridControl gridControl1;
private DevExpress.XtraGrid.Views.Grid.GridView gridView1;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn11;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn12;
private DevExpress.XtraGrid.Columns.GridColumn productid;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn13;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn14;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn15;
@ -931,5 +939,6 @@ namespace MES.Form
private DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit repositoryItemtxtunit;
private DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit repositoryItemtxtstockid;
private DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit repositoryItemtxtproductid;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn12;
}
}

View File

@ -0,0 +1,394 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WinformGeneralDeveloperFrame;
using WinformGeneralDeveloperFrame.Commons;
using DevExpress.XtraLayout;
using MES.Entity;
using System.Data.Entity.Migrations;
using System.Data.Entity;
using CCWin.SkinClass;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraRichEdit.Layout;
namespace MES.Form
{
public partial class Frmsale : FrmBaseForm
{
private Dictionary<string, string> fieldDictionary = new Dictionary<string, string>();
public Frmsale()
{
InitializeComponent();
}
private void Frmsale_Load(object sender, EventArgs e)
{
InitFrom(xtraTabControl1,grdList,grdListView,new LayoutControlGroup[]{layoutControlGroup1},new saleInfo(),gridControl1,new string[]{ "txtsaleordercode" });
InitSearchDicData();
repositoryItemGridLookUpEdit1.EditValueChanged += RepositoryItemGridLookUpEdit1_EditValueChanged;
}
/// <summary>
/// 数据源初始化
/// </summary>
/// <returns></returns>
private void Init()
{
txtcustomerid.Properties.DataSource = GetDataTableUtils.SqlTable("客户");
repositoryItemtxtcustomerid.DataSource= GetDataTableUtils.SqlTable("客户");
txtcustomertype.Properties.DataSource = GetDataTableUtils.SqlTable("客户类别");
repositoryItemtxtcustomertype.DataSource= GetDataTableUtils.SqlTable("客户类别");
txtcontactuser.Properties.DataSource = GetDataTableUtils.SqlTable("用户");
repositoryItemtxtcontactuser.DataSource= GetDataTableUtils.SqlTable("用户");
txtsalesman.Properties.DataSource = GetDataTableUtils.SqlTable("用户");
repositoryItemtxtsalesman.DataSource= GetDataTableUtils.SqlTable("用户");
txtcreatorId.Properties.DataSource = GetDataTableUtils.SqlTable("用户");
repositoryItemtxtpreparedby.DataSource= GetDataTableUtils.SqlTable("用户");
repositoryItemtxtunit.DataSource = GetDataTableUtils.SqlTable("计量单位");
repositoryItemtxtwarehouse.DataSource = GetDataTableUtils.SqlTable("仓库");
txtcreatorId.Properties.DataSource= GetDataTableUtils.SqlTable("用户");
}
/// <summary>
/// 搜索字段
/// </summary>
/// <returns></returns>
private void InitSearchDicData()
{
fieldDictionary.Add("销售单号","saleordercode");
fieldDictionary.Add("订单日期","orderdate");
fieldDictionary.Add("客户单号","customerordercode");
fieldDictionary.Add("业务员","salesman");
fieldDictionary.Add("完货日期","finishdate");
fieldDictionary.Add("制单人", "creatorId");
}
public override void InitgrdListDataSource()
{
using (var con=new MESDB())///
{
grdList.DataSource=con.saleInfo.ToList();
}
Init();
}
/// <summary>
/// 字段为空校验
/// </summary>
/// <returns></returns>
public override bool CheckInput()
{
if(string.IsNullOrEmpty(txtorderdate.EditValue.ToString()))
{
"订单日期不能为空".ShowWarning();
txtorderdate.Focus();
return false;
}
if(string.IsNullOrEmpty(txtcustomerid.EditValue.ToString()))
{
"客户不能为空".ShowWarning();
txtcustomerid.Focus();
return false;
}
if(string.IsNullOrEmpty(txtcustomertype.EditValue.ToString()))
{
"客户类型不能为空".ShowWarning();
txtcustomertype.Focus();
return false;
}
if(string.IsNullOrEmpty(txtcontactuser.EditValue.ToString()))
{
"联系人不能为空".ShowWarning();
txtcontactuser.Focus();
return false;
}
if(string.IsNullOrEmpty(txtcontactphone.EditValue.ToString()))
{
"联系电话不能为空".ShowWarning();
txtcontactphone.Focus();
return false;
}
if(string.IsNullOrEmpty(txtdeliveraddress.EditValue.ToString()))
{
"送货地址不能为空".ShowWarning();
txtdeliveraddress.Focus();
return false;
}
if(string.IsNullOrEmpty(txtsalesman.EditValue.ToString()))
{
"业务员不能为空".ShowWarning();
txtsalesman.Focus();
return false;
}
if(string.IsNullOrEmpty(txtfinishdate.EditValue.ToString()))
{
"完货日期不能为空".ShowWarning();
txtfinishdate.Focus();
return false;
}
if(string.IsNullOrEmpty(txtcreatorId.EditValue.ToString()))
{
"制单人不能为空".ShowWarning();
txtcreatorId.Focus();
return false;
}
return true;
}
/// <summary>
/// 保存
/// </summary>
/// <returns></returns>
public override bool SaveFunction()
{
string code = "SO" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour +
DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond.ToString("D3");
DataTable dt = gridControl1.DataSource as DataTable;
try
{
saleInfo info= (saleInfo)this.ControlDataToModel(new saleInfo());
using (var db = new MESDB())
{
using (var tran=db.Database.BeginTransaction())
{
try
{
Dictionary<string, List<saledetailInfo>> dic =
dt.GetDataTableData<saledetailInfo>();
if (info.id == 0)//新增
{
info.saleordercode = code;
db.saleInfo.Add(info);
db.SaveChanges();
txtid.Text = info.id.ToString();
txtsaleordercode.Text = code;
if (dt != null)
{
List<saledetailInfo> detaiListAdd =
dic["Add"];
detaiListAdd.ForEach(a => a.saleid = info.id);
db.saledetailInfo.AddRange(detaiListAdd);
db.SaveChanges();
}
}
else //更新
{
db.Entry(info).State = EntityState.Modified;
db.SaveChanges();
if (dt != null)
{
List<saledetailInfo> detaiListAdd =
dic["Add"];
detaiListAdd.ForEach(a => a.saleid = info.id);
db.saledetailInfo.AddRange(detaiListAdd);
List<saledetailInfo> detaiListEdit =
dic["Edit"];
detaiListEdit.ForEach((a) =>
{
db.Entry(a).State = EntityState.Modified;
});
List<saledetailInfo> detaiListDel =
dic["Del"];
detaiListDel.ForEach((a) =>
{
db.Entry(a).State = EntityState.Deleted;
});
db.SaveChanges();
}
}
tran.Commit();
}
catch (Exception ex)
{
tran.Rollback();
ex.Message.ShowError();
return false;
}
finally
{
tran.Dispose();
}
}
}
}
catch (Exception ex)
{
ex.Message.ShowError();
return false;
}
return true;
}
/// <summary>
/// 删除
/// </summary>
/// <returns></returns>
public override bool DelFunction()
{
try
{
saleInfo info = (saleInfo)this.ControlDataToModel(new saleInfo());
using (var db = new MESDB())
{
db.Entry(info).State=EntityState.Deleted;
db.SaveChanges();
}
}
catch (Exception ex)
{
ex.Message.ShowError();
return false;
}
return true;
}
/// <summary>
/// 搜索
/// </summary>
/// <returns></returns>
public override void SearchFunction()
{
FrmSearch frm = new FrmSearch(fieldDictionary);
if (frm.ShowDialog()==DialogResult.OK)
{
string sql = frm.sql;
using (var db = new MESDB())
{
if (string.IsNullOrEmpty(sql))
{
grdList.DataSource = db.saleInfo.SqlQuery("select * from sale").ToList();
}
else
{
grdList.DataSource = db.saleInfo.SqlQuery($"select * from sale where {sql}").ToList();
}
}
}
}
public override void gridControlMouseDoubleClickFunction(object sender, EventArgs e)
{
Initresgridcontrollookupedit();
saleInfo info = grdListView.GetFocusedRow() as saleInfo;
if (info != null)
{
using (var db = new MESDB())
{
gridControl1.DataSource = db.saledetailInfo.Where(p => p.saleid == info.id).ToList().ToDataTable();
gridView1.BestFitColumns();
quotationInfo quotation = db.quotationInfo.Where(p => p.customeruser == info.customerid).ToList()
.FirstOrDefault();
repositoryItemGridLookUpEdit1.DataSource =
db.quotationdetailInfo.Where(p => p.quotationid == quotation.id).ToList();
}
}
}
public override void AddFunction()
{
txtorderdate.DateTime = DateTime.Now;
gridControl1.DataSource = new List<saledetailInfo>().ToDataTable();
}
private void toolStripMenuItemAdd_Click(object sender, EventArgs e)
{
gridView1.AddNewRow();
}
private void toolStripMenuItemDel_Click(object sender, EventArgs e)
{
gridView1.DeleteRow(gridView1.FocusedRowHandle);
}
private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
{
if (string.IsNullOrEmpty(gridView1.GetFocusedDataRow()["productid"].ToString()))
{
"请选择产品".ShowTips();
return;
}
if (!string.IsNullOrEmpty(gridView1.GetFocusedDataRow()["unitprice"].ToString()) &&
!string.IsNullOrEmpty(gridView1.GetFocusedDataRow()["salenumber"].ToString()))
{
gridView1.GetFocusedDataRow()["money"] = decimal.Multiply(
gridView1.GetFocusedDataRow()["unitprice"].ToDecimal(0),
gridView1.GetFocusedDataRow()["salenumber"].ToDecimal(0));
;
}
gridView1.BestFitColumns();
}
private void txtcustomerid_EditValueChanged(object sender, EventArgs e)
{
Initresgridcontrollookupedit();
using (var db = new MESDB())
{
if (db.quotationInfo.ToList().Count > 0&& db.quotationInfo.ToList()
.Where(p => p.customeruser == txtcustomerid.EditValue.ToString().ToInt16()).Count()>0)
{
quotationInfo quotation = db.quotationInfo.ToList()
.Where(p => p.customeruser == txtcustomerid.EditValue.ToString().ToInt16()).First();
repositoryItemGridLookUpEdit1.DataSource =
db.quotationdetailInfo.Where(p => p.quotationid == quotation.id).ToList();
}
if (txtcustomerid.EditValue != null)
{
int id = txtcustomerid.EditValue.ToString().ToInt16();
customerInfo customer = db.customerInfo.Where(p => p.id == id)
.First();
if (customer != null)
{
txtcustomercode.Text = customer.customercode;
txtcustomertype.EditValue = customer.customertype;
txtcontactuser.EditValue = customer.contactuser;
txtdeliveraddress.Text = customer.address;
txtcontactphone.Text = customer.phonenumber;
}
}
}
}
//GridColumn col1 = new GridColumn();
//col1=repositoryItemGridLookUpEdit1View.Columns.AddField("productid");
//col1.Caption = "产品名称";
//col1.Visible = true;
private void Initresgridcontrollookupedit()
{
GridColumn col1 = new GridColumn(){Caption = "产品",FieldName = "productid",Visible = false};
GridColumn col7 = new GridColumn() { Caption = "产品名称", FieldName = "productname", Visible = true };
GridColumn col2 = new GridColumn() { Caption = "规格", FieldName = "spec", Visible = true };
GridColumn col3 = new GridColumn() { Caption = "报价数量", FieldName = "number", Visible = true };
GridColumn col5 = new GridColumn() { Caption = "单价", FieldName = "unitprice", Visible = true };
GridColumn col6 = new GridColumn() { Caption = "金额", FieldName = "money", Visible = true };
GridColumn col4 = new GridColumn() { Caption = "id", FieldName = "id", Visible = false };
repositoryItemGridLookUpEdit1View.Columns.AddRange(new GridColumn[]{col1, col7, col2,col3,col5,col6,col4});
}
private void RepositoryItemGridLookUpEdit1_EditValueChanged(object sender, EventArgs e)
{
using (var db = new MESDB())
{
GridLookUpEdit look = sender as GridLookUpEdit;
quotationdetailInfo quotationdetail = look.Properties.View.GetFocusedRow() as quotationdetailInfo;
gridView1.GetFocusedDataRow()["productspec"] = quotationdetail.spec;
gridView1.GetFocusedDataRow()["unit"] = quotationdetail.unit;
gridView1.GetFocusedDataRow()["warehouse"] = quotationdetail.stockid;
gridView1.GetFocusedDataRow()["productcode"] = quotationdetail.productcode;
gridView1.GetFocusedDataRow()["productid"] = quotationdetail.productid;
gridView1.GetFocusedDataRow()["unitprice"] = quotationdetail.unitprice;
gridView1.GetFocusedDataRow()["salenumber"] = quotationdetail.number;
//LookUpEdit look = sender as LookUpEdit;
//int quotationid = look.EditValue.ToInt32();
//quotationdetailInfo product = db.productInfo.Where(p => p.id == productid).FirstOrDefault();
//DataTable dt = gridControl1.DataSource as DataTable;
//gridView1.GetFocusedDataRow()["spec"] = product.spec;
//gridView1.GetFocusedDataRow()["unit"] = product.unit;
//gridView1.GetFocusedDataRow()["stockid"] = product.warehouse;
//gridView1.GetFocusedDataRow()["productcode"] = product.productcode;
//gridView1.GetFocusedDataRow()["productname"] = product.productname;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,277 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WinformGeneralDeveloperFrame;
using WinformGeneralDeveloperFrame.Commons;
using DevExpress.XtraLayout;
using MES.Entity;
using System.Data.Entity.Migrations;
using System.Data.Entity;
namespace MES.Form
{
public partial class Frmsaledetail : FrmBaseForm
{
private Dictionary<string, string> fieldDictionary = new Dictionary<string, string>();
public Frmsaledetail()
{
InitializeComponent();
}
private void Frmsaledetail_Load(object sender, EventArgs e)
{
InitFrom(xtraTabControl1,grdList,grdListView,new LayoutControlGroup[]{layoutControlGroup1},new saledetailInfo());
InitSearchDicData();
}
/// <summary>
/// 数据源初始化
/// </summary>
/// <returns></returns>
private void Init()
{
txtproductid.Properties.DataSource = GetDataTableUtils.SqlTable("产品");
repositoryItemtxtproductid.DataSource= GetDataTableUtils.SqlTable("产品");
txtunit.Properties.DataSource = GetDataTableUtils.SqlTable("计量单位");
repositoryItemtxtunit.DataSource= GetDataTableUtils.SqlTable("计量单位");
txtwarehouse.Properties.DataSource = GetDataTableUtils.SqlTable("仓库");
repositoryItemtxtwarehouse.DataSource= GetDataTableUtils.SqlTable("仓库");
}
/// <summary>
/// 搜索字段
/// </summary>
/// <returns></returns>
private void InitSearchDicData()
{
fieldDictionary.Add("交货日期","deliverdate");
fieldDictionary.Add("仓库","warehouse");
fieldDictionary.Add("产品编号","productcode");
fieldDictionary.Add("销售单号","salecode");
}
public override void InitgrdListDataSource()
{
using (var con=new MESDB())///
{
grdList.DataSource=con.saledetailInfo.ToList();
}
Init();
}
/// <summary>
/// 字段为空校验
/// </summary>
/// <returns></returns>
public override bool CheckInput()
{
if(string.IsNullOrEmpty(txtproductid.EditValue.ToString()))
{
"产品不能为空".ShowWarning();
txtproductid.Focus();
return false;
}
if(string.IsNullOrEmpty(txtproductspec.EditValue.ToString()))
{
"规格型号不能为空".ShowWarning();
txtproductspec.Focus();
return false;
}
if(string.IsNullOrEmpty(txtsalenumber.EditValue.ToString()))
{
"数量不能为空".ShowWarning();
txtsalenumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtunit.EditValue.ToString()))
{
"计量单位不能为空".ShowWarning();
txtunit.Focus();
return false;
}
if(string.IsNullOrEmpty(txtunitprice.EditValue.ToString()))
{
"单价不能为空".ShowWarning();
txtunitprice.Focus();
return false;
}
if(string.IsNullOrEmpty(txtmoney.EditValue.ToString()))
{
"金额不能为空".ShowWarning();
txtmoney.Focus();
return false;
}
if(string.IsNullOrEmpty(txtdeliverdate.EditValue.ToString()))
{
"交货日期不能为空".ShowWarning();
txtdeliverdate.Focus();
return false;
}
if(string.IsNullOrEmpty(txtwarehouse.EditValue.ToString()))
{
"仓库不能为空".ShowWarning();
txtwarehouse.Focus();
return false;
}
if(string.IsNullOrEmpty(txtreadynumber.EditValue.ToString()))
{
"已排产量不能为空".ShowWarning();
txtreadynumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtnoreadynumber.EditValue.ToString()))
{
"待排产量不能为空".ShowWarning();
txtnoreadynumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtfinishnumber.EditValue.ToString()))
{
"已完工量不能为空".ShowWarning();
txtfinishnumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtoutnumber.EditValue.ToString()))
{
"已出货量不能为空".ShowWarning();
txtoutnumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtreturnnumber.EditValue.ToString()))
{
"退货量不能为空".ShowWarning();
txtreturnnumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtnodelivernumber.EditValue.ToString()))
{
"未交货数量不能为空".ShowWarning();
txtnodelivernumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtdelivernumber.EditValue.ToString()))
{
"实际交货数量不能为空".ShowWarning();
txtdelivernumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtclosenumber.EditValue.ToString()))
{
"已结算数量不能为空".ShowWarning();
txtclosenumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtnoclosenumber.EditValue.ToString()))
{
"未结算数量不能为空".ShowWarning();
txtnoclosenumber.Focus();
return false;
}
if(string.IsNullOrEmpty(txtmaterialcost.EditValue.ToString()))
{
"物料成本不能为空".ShowWarning();
txtmaterialcost.Focus();
return false;
}
if(string.IsNullOrEmpty(txtrealmaterialcost.EditValue.ToString()))
{
"实际物料成本不能为空".ShowWarning();
txtrealmaterialcost.Focus();
return false;
}
if(string.IsNullOrEmpty(txtproductcode.EditValue.ToString()))
{
"产品编号不能为空".ShowWarning();
txtproductcode.Focus();
return false;
}
//if(string.IsNullOrEmpty(txtsaleid.EditValue.ToString()))
//{
// "销售主表不能为空".ShowWarning();
// txtsaleid.Focus();
// return false;
//}
if(string.IsNullOrEmpty(txtsalecode.EditValue.ToString()))
{
"销售单号不能为空".ShowWarning();
txtsalecode.Focus();
return false;
}
return true;
}
/// <summary>
/// 保存
/// </summary>
/// <returns></returns>
public override bool SaveFunction()
{
try
{
saledetailInfo info= (saledetailInfo)this.ControlDataToModel(new saledetailInfo());
using (var db = new MESDB())
{
db.saledetailInfo.AddOrUpdate(info);
db.SaveChanges();
}
}
catch (Exception ex)
{
ex.Message.ShowError();
return false;
}
return true;
}
/// <summary>
/// 删除
/// </summary>
/// <returns></returns>
public override bool DelFunction()
{
try
{
saledetailInfo info = (saledetailInfo)this.ControlDataToModel(new saledetailInfo());
using (var db = new MESDB())
{
db.Entry(info).State=EntityState.Deleted;
db.SaveChanges();
}
}
catch (Exception ex)
{
ex.Message.ShowError();
return false;
}
return true;
}
/// <summary>
/// 搜索
/// </summary>
/// <returns></returns>
public override void SearchFunction()
{
FrmSearch frm = new FrmSearch(fieldDictionary);
if (frm.ShowDialog()==DialogResult.OK)
{
string sql = frm.sql;
using (var db = new MESDB())
{
if (string.IsNullOrEmpty(sql))
{
grdList.DataSource = db.saledetailInfo.SqlQuery("select * from saledetail").ToList();
}
else
{
grdList.DataSource = db.saledetailInfo.SqlQuery($"select * from saledetail where {sql}").ToList();
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -51,10 +51,13 @@ namespace WinformGeneralDeveloperFrame
this.xtraTab = xtraTab;
this.gridControl = gridControl;
this.gridView = gridView;
this.gridView.BestFitColumns();
this.controlGroups = controlGroups;
InitFormFunction();
InitToolBtntatus(EFormStatus.eInit);
InitEvent();
}
public void InitFrom(XtraTabControl xtraTab, GridControl gridControl, GridView gridView, LayoutControlGroup[] controlGroups, object DataType,GridControl griddetail,string[] readcontrols)
{
if (griddetail != null)
@ -73,6 +76,11 @@ namespace WinformGeneralDeveloperFrame
xtraTab.SelectedPageChanged += xtraTabControl1_SelectedPageChanged;
gridControl.MouseDoubleClick += gridControl_MouseDoubleClick;
}
public virtual void InitFormFunction()
{
}
private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
{
@ -143,7 +151,7 @@ namespace WinformGeneralDeveloperFrame
"保存成功!".ShowTips();
InitToolBtntatus(EFormStatus.eView);
InitgrdListDataSource();
InitgrdListDataSourceFunction();
SetControlStatus(controlGroups, true);
}
@ -193,6 +201,19 @@ namespace WinformGeneralDeveloperFrame
}
}
public void InitgrdListDataSourceFunction()
{
if (gridView != null)
{
gridView.BestFitColumns();
}
if (gridViewDetail != null)
{
gridViewDetail.BestFitColumns();
}
InitgrdListDataSource();
}
public virtual void InitgrdListDataSource()
{
@ -233,7 +254,7 @@ namespace WinformGeneralDeveloperFrame
if (DelFunction())
{
InitToolBtntatus(EFormStatus.eDelete);
InitgrdListDataSource();
InitgrdListDataSourceFunction();
ClearScreen();
}
}
@ -503,7 +524,7 @@ namespace WinformGeneralDeveloperFrame
private void FrmBaseForm_Load(object sender, EventArgs e)
{
InitgrdListDataSource();
InitgrdListDataSourceFunction();
}
}
/// <summary>

View File

@ -1,28 +1,29 @@
DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemTreeListLookUpEdit, DevExpress.XtraTreeList.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraNavBar.NavBarControl, DevExpress.XtraNavBar.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraBars.Ribbon.RibbonControl, DevExpress.XtraBars.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.ComboBoxEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.PictureEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraCharts.ChartControl, DevExpress.XtraCharts.v19.2.UI, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.ProgressBarControl, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemDateEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemSearchLookUpEdit, DevExpress.XtraGrid.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraBars.BarManager, DevExpress.XtraBars.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.GridLookUpEdit, DevExpress.XtraGrid.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraTabbedMdi.XtraTabbedMdiManager, DevExpress.XtraBars.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.DateEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.SearchLookUpEdit, DevExpress.XtraGrid.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.ImageComboBoxEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraLayout.LayoutControl, DevExpress.XtraLayout.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.TextEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraTreeList.TreeList, DevExpress.XtraTreeList.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.LookUpEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraWizard.WizardControl, DevExpress.XtraWizard.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemComboBox, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraDataLayout.DataLayoutControl, DevExpress.XtraLayout.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.TreeListLookUpEdit, DevExpress.XtraTreeList.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraNavBar.NavBarControl, DevExpress.XtraNavBar.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemDateEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.ComboBoxEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemTreeListLookUpEdit, DevExpress.XtraTreeList.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.LookUpEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.ProgressBarControl, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemSearchLookUpEdit, DevExpress.XtraGrid.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemGridLookUpEdit, DevExpress.XtraGrid.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraBars.Ribbon.RibbonControl, DevExpress.XtraBars.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraCharts.ChartControl, DevExpress.XtraCharts.v19.2.UI, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.PopupGalleryEdit, DevExpress.XtraBars.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraTabbedMdi.XtraTabbedMdiManager, DevExpress.XtraBars.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.PictureEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraBars.BarManager, DevExpress.XtraBars.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.Repository.RepositoryItemComboBox, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.SearchLookUpEdit, DevExpress.XtraGrid.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraWizard.WizardControl, DevExpress.XtraWizard.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.TreeListLookUpEdit, DevExpress.XtraTreeList.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.GridLookUpEdit, DevExpress.XtraGrid.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.ImageComboBoxEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.TextEdit, DevExpress.XtraEditors.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraLayout.LayoutControl, DevExpress.XtraLayout.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraDataLayout.DataLayoutControl, DevExpress.XtraLayout.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraTreeList.TreeList, DevExpress.XtraTreeList.v19.2, Version=19.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a

View File

@ -143,6 +143,8 @@
<Compile Include="Entity\productInfo.cs" />
<Compile Include="Entity\quotationdetailInfo.cs" />
<Compile Include="Entity\quotationInfo.cs" />
<Compile Include="Entity\saledetailInfo.cs" />
<Compile Include="Entity\saleInfo.cs" />
<Compile Include="Entity\stockInfo.cs" />
<Compile Include="Entity\supplierInfo.cs" />
<Compile Include="Entity\sysDeptInfo.cs" />
@ -177,6 +179,18 @@
<Compile Include="Form\Frmquotation.designer.cs">
<DependentUpon>Frmquotation.cs</DependentUpon>
</Compile>
<Compile Include="Form\Frmsale.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form\Frmsale.designer.cs">
<DependentUpon>Frmsale.cs</DependentUpon>
</Compile>
<Compile Include="Form\Frmsaledetail.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form\Frmsaledetail.designer.cs">
<DependentUpon>Frmsaledetail.cs</DependentUpon>
</Compile>
<Compile Include="Form\Frmstock.cs">
<SubType>Form</SubType>
</Compile>
@ -351,6 +365,12 @@
<EmbeddedResource Include="Form\Frmquotation.resx">
<DependentUpon>Frmquotation.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form\Frmsale.resx">
<DependentUpon>Frmsale.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form\Frmsaledetail.resx">
<DependentUpon>Frmsaledetail.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form\Frmstock.resx">
<DependentUpon>Frmstock.cs</DependentUpon>
</EmbeddedResource>