📄 dlgdataadvmodel.cs
字号:
this.label9.Text = "数量:";
this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label10
//
this.label10.Location = new System.Drawing.Point(184, 168);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(48, 23);
this.label10.TabIndex = 23;
this.label10.Text = "单价:";
this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label11
//
this.label11.Location = new System.Drawing.Point(184, 200);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(64, 23);
this.label11.TabIndex = 24;
this.label11.Text = "总金额:";
this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label12
//
this.label12.Location = new System.Drawing.Point(16, 232);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(48, 23);
this.label12.TabIndex = 25;
this.label12.Text = "备注:";
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// txtPayNum
//
this.txtPayNum.EditValue = new System.Decimal(new int[] {
0,
0,
0,
0});
this.txtPayNum.EnterMoveNextControl = true;
this.txtPayNum.Location = new System.Drawing.Point(88, 200);
this.txtPayNum.Name = "txtPayNum";
//
// txtPayNum.Properties
//
this.txtPayNum.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton()});
this.txtPayNum.Properties.MaxValue = new System.Decimal(new int[] {
1000,
0,
0,
0});
this.txtPayNum.Properties.UseCtrlIncrement = false;
this.txtPayNum.Size = new System.Drawing.Size(88, 21);
this.txtPayNum.TabIndex = 8;
this.txtPayNum.EditValueChanged += new System.EventHandler(this.txtPayNum_EditValueChanged);
//
// txtPaperName
//
this.txtPaperName.EditValue = "";
this.txtPaperName.Enabled = false;
this.txtPaperName.EnterMoveNextControl = true;
this.txtPaperName.Location = new System.Drawing.Point(88, 72);
this.txtPaperName.Name = "txtPaperName";
//
// txtPaperName.Properties
//
this.txtPaperName.Properties.AppearanceDisabled.ForeColor = System.Drawing.Color.Black;
this.txtPaperName.Properties.AppearanceDisabled.Options.UseForeColor = true;
this.txtPaperName.Properties.ReadOnly = true;
this.txtPaperName.Size = new System.Drawing.Size(184, 21);
this.txtPaperName.TabIndex = 1;
//
// DlgDataAdvModel
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(378, 344);
this.Controls.Add(this.txtPaperName);
this.Controls.Add(this.txtPayNum);
this.Controls.Add(this.txtPaperSpace);
this.Controls.Add(this.lblTitle);
this.Controls.Add(this.txtPaySum);
this.Controls.Add(this.txtColor);
this.Controls.Add(this.txtPayPrice);
this.Controls.Add(this.txtPaperSpaceNum);
this.Controls.Add(this.txtPayUnit);
this.Controls.Add(this.txtAdvSpec);
this.Controls.Add(this.txtMemo);
this.Controls.Add(this.txtCode);
this.Controls.Add(this.label12);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "DlgDataAdvModel";
this.Controls.SetChildIndex(this.label1, 0);
this.Controls.SetChildIndex(this.label2, 0);
this.Controls.SetChildIndex(this.label4, 0);
this.Controls.SetChildIndex(this.label5, 0);
this.Controls.SetChildIndex(this.label6, 0);
this.Controls.SetChildIndex(this.label7, 0);
this.Controls.SetChildIndex(this.label8, 0);
this.Controls.SetChildIndex(this.label9, 0);
this.Controls.SetChildIndex(this.label10, 0);
this.Controls.SetChildIndex(this.label11, 0);
this.Controls.SetChildIndex(this.label12, 0);
this.Controls.SetChildIndex(this.btnCancel, 0);
this.Controls.SetChildIndex(this.btnAccept, 0);
this.Controls.SetChildIndex(this.txtCode, 0);
this.Controls.SetChildIndex(this.txtMemo, 0);
this.Controls.SetChildIndex(this.txtAdvSpec, 0);
this.Controls.SetChildIndex(this.txtPayUnit, 0);
this.Controls.SetChildIndex(this.txtPaperSpaceNum, 0);
this.Controls.SetChildIndex(this.txtPayPrice, 0);
this.Controls.SetChildIndex(this.txtColor, 0);
this.Controls.SetChildIndex(this.txtPaySum, 0);
this.Controls.SetChildIndex(this.lblTitle, 0);
this.Controls.SetChildIndex(this.txtPaperSpace, 0);
this.Controls.SetChildIndex(this.txtPayNum, 0);
this.Controls.SetChildIndex(this.txtPaperName, 0);
((System.ComponentModel.ISupportInitialize)(this.txtCode.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtMemo.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtAdvSpec.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtPayUnit.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtPaperSpaceNum.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtPayPrice.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtColor.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtPaySum.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtPaperSpace.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtPayNum.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.txtPaperName.Properties)).EndInit();
this.ResumeLayout(false);
} #endregion #endregion #region Variable int mode = 0; //0-Browse 1-Append 2-Edit bool quickappend = false; DataView dvFind; DataRow orow; DlgFrmMsg msgBox; WWAM.Forms.Child.ChildAdvModel mainForm; #endregion #region FormEvent protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
msgBox = new DlgFrmMsg(this);
}
#endregion #region Return Value public DataRow GetRow() { orow["Code"] = this.txtCode.Text.Trim(); //orow["PaperName"] = this.txtPaperName.Text.Trim(); orow["PaperSpaceNum"] = this.txtPaperSpaceNum.Text.Trim(); orow["PaperSpace"] = this.txtPaperSpace.Text.Trim(); orow["AdvSpec"] = this.txtAdvSpec.Text.Trim(); orow["Color"] = this.txtColor.Text.Trim(); orow["Memo"] = this.txtMemo.Text.Trim(); orow["PayNum"] = (float)this.txtPayNum.Value; orow["PaySum"] = (float)this.txtPaySum.Value; orow["PayUnit"] = this.txtPayUnit.Text.Trim(); orow["PayPrice"] = (float)this.txtPayPrice.Value; return orow; } public bool IsChanged { get{return edited;} } #endregion #region CanColse protected override bool CanClose()
{
if(mode==2 && !edited)
{
return true;
}
if(DataRepeat())
{
msgBox.ShowWarning("指定的模版编号已被占用!");
return false;
}
if(ControlEmpty(this.txtCode,"请输入模版编号"))return false;
//if(ControlEmpty(this.txtPaperName,"请选择报刊"))return false;
if(ControlEmpty(this.txtPaperSpaceNum,"请输入版号"))return false;
if(ControlEmpty(this.txtPaperSpace,"请选择版面"))return false;
if(this.quickappend && mode == 1 && this.mainForm!=null)
{
QuickAppend(mainForm);
return false;
}
return base.CanClose ();
}
#endregion #region OnFormShow protected override void OnFormShow()
{
base.OnFormShow ();
this.txtCode.Focus();
}
#endregion #region ShowDialog public DialogResult ShowDialog(string paper, bool quickappend,DataTable dtfind,DataTable dtType) { this.quickappend = quickappend; DataBind(dtType); this.orow = WWAM.DBA.GetRow.GetAdvModelRow(); this.orow["Used"] = true; this.orow["PaperName"] = paper; this.DataInit(); this.dvFind = new DataView(dtfind); this.edited = false; this.mode = 1; return base.ShowDialog(); } public DialogResult ShowDialog(DataRow dr , DataTable dtfind,DataTable dtType) { quickappend = false; DataBind(dtType); this.orow = WWAM.DBA.DRPro.CloneDataRow(dr); this.DataSetting(); this.dvFind = new DataView(dtfind); this.edited = false; this.mode = 2; return base.ShowDialog(); } #endregion #region DataMethod void DataBind(DataTable dtType) { ComboDataBind(this.txtPaperSpace,dtType,"Code","Type = 6"); ComboDataBind(this.txtColor,dtType,"Code","Type = 2"); ComboDataBind(this.txtPayUnit,dtType,"Code","Type = 3"); } void DataInit() { DataSetting(); this.txtPaperSpace.SelectedIndex = 0; this.txtPayUnit.SelectedIndex = 0; this.txtColor.SelectedIndex = 0; } void DataSetting() { this.txtCode.Text = (string)orow["Code"]; this.txtPaperName.Text = (string)orow["PaperName"]; this.txtPaperSpaceNum.Text = (string)orow["PaperSpaceNum"]; this.txtPaperSpace.Text = (string)orow["PaperSpace"]; this.txtAdvSpec.Text = (string)orow["AdvSpec"]; this.txtColor.Text = (string)orow["Color"]; this.txtPayNum.Value = (decimal)((float)orow["PayNum"]); this.txtPaySum.EditValue = (float)orow["PaySum"]; this.txtPayUnit.Text = (string)orow["PayUnit"]; this.txtPayPrice.EditValue = (float)orow["PayPrice"]; this.txtMemo.Text = (string)orow["Memo"]; } public void ClearData() { orow = WWAM.DBA.GetRow.GetAdvModelRow(); DataSetting(); } #endregion #region Method bool DataRepeat() { if(this.txtCode.Text.Trim()==string.Empty) return false; if(mode==1) { dvFind.RowFilter = string.Format("Code = '{0}' ",this.txtCode.Text.Trim()); } else if(mode==2) { dvFind.RowFilter = string.Format("Code = '{0}' and AdvModelid <> {1}",this.txtCode.Text.Trim(),this.orow["AdvModelid"]); } return dvFind.Count>0; } #endregion #region EditValue Changed private void txtPayPrice_EditValueChanged(object sender, System.EventArgs e)
{
BaseEditor_EditValueChanged(sender,e); this.txtPaySum.Value = this.txtPayNum.Value*this.txtPayPrice.Value; }
private void txtPayNum_EditValueChanged(object sender, System.EventArgs e)
{
BaseEditor_EditValueChanged(sender,e); this.txtPaySum.Value = this.txtPayNum.Value*this.txtPayPrice.Value; } #endregion
#region QuickAppend
int QuickAppend(WWAM.Forms.Child.ChildAdvModel form)
{
DataRow _ndr = this.GetRow();
int rv = form.BaseDB.RunSPGetInt("iAdvModelInsert",_ndr,0);
if(rv > 0)
{
_ndr["AdvModelid"] = rv;
RefreshMainForm(form,_ndr);
this.txtCode.Text = "";
this.txtCode.Focus();
}
else
{
string title = "广告模版添加失败";
switch(rv)
{
case -1:
this.msgBox.ShowWarning("指定的广告模版已被占用。",title);
break;
case -99:
this.msgBox.ShowWarning("数据库执行错误!\r\n"+form.BaseDB.LastError,title);
break;
default:
this.msgBox.ShowWarning("未知错误!\r\n错误码:"+rv.ToString(),title);
break;
}
}
return rv;
}
delegate void refreshMainFormDelegate(WWAM.Forms.Child.ChildAdvModel form, DataRow dr);
void refreshMainFormMethod(WWAM.Forms.Child.ChildAdvModel form, DataRow dr)
{
WWAM.DBA.DTPro.AddRow(form.dtAdvModel,dr);
form.ShowDetail();
}
void RefreshMainForm(WWAM.Forms.Child.ChildAdvModel form, DataRow dr)
{
if(form.IsHandleCreated)
form.BeginInvoke(new refreshMainFormDelegate(refreshMainFormMethod), new object[]{form, dr});
else
refreshMainFormMethod(form, dr);
}
#endregion
}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -