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 System.IO;
using LYFZ.Software.MainBusiness.DoorCityProcess;
using LYFZ.ComponentLibrary;
using System.Collections;
namespace LYFZ.Software.MainBusiness.InventoryManagement
{
public partial class FrmFixedAssetManagement : LYFZ.Software.UI.InventoryManagement.FrmFixedAssetManagement
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
LYFZ.BLL.BLL_ErpFixedAssetManagement fambll = new BLL.BLL_ErpFixedAssetManagement();
private delegate void UpdateControl();
public FrmFixedAssetManagement()
{
this.Load += FrmFixedAssetManagement_Load;
this.Shown += FrmFixedAssetManagement_Shown;
this.btnReset.Click += btnReset_Click;
this.btnSaveed.Click += btnSaveed_Click;
this.btnDelete.Click += btnDelete_Click;
this.btnRemovePhoto.Click += btnRemovePhoto_Click;
this.btnBrowse.Click += btnBrowse_Click;
this.btnSet.Click += btnSet_Click;
this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
this.btnClose.Click += btnClose_Click;
this.pictPhoto.Click += pictPhoto_Click;
this.txtAssetsQuantity.KeyPress += txtAssetsQuantity_KeyPress;
this.txtAssetsPrice.KeyPress += txtAssetsPrice_KeyPress;
this.treevPathPhoto.AfterSelect += treevPathPhoto_AfterSelect;
this.cmbtreevFixedAssetsClassQuerie.ComboBoxTree_NodeMouseClick += cmbtreevFixedAssetsClassQuerie_ComboBoxTree_NodeMouseClick;
}
DataTable dtUser = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable;
Hashtable htDataFile = new Hashtable();
///
/// 员工编号
///
string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
///
/// 窗体加载事件
///
///
///
void FrmFixedAssetManagement_Load(object sender, EventArgs e)
{
this.dgvData.DataColumns("编号,名称,类别,数量,规格,价格,保管人,购买时间,备注", strHideField: "编号");
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.txtAssetsPerson, IsFirstNodeNull: true, IsShowAdmin: true);
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAABY", this.cmbtreevFixedAssetsClass);
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAABY", this.cmbtreevFixedAssetsClassQuerie, IsFirstNodeNull: true, IsFirstNodeName: "全部");
this.cmbtreevFixedAssetsClassQuerie.TextFindTag("全部");
}
///
/// 窗体加载事件
///
///
///
void FrmFixedAssetManagement_Shown(object sender, EventArgs e)
{
//数码安排版本权限
bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
VersionControl.VersionFunctionEnum.库存管理固定资产管理);
if (!b)
{
this.Close();
return;
}
this.txtAssetsDate.DateValue = DateTime.Now.ToString("yyyy-MM-dd");
this.btnSaveed.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.FixedAssetManagementCompetence, CustomAttributes.OperatingAuthority.Add);
this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.FixedAssetManagementCompetence, CustomAttributes.OperatingAuthority.Delete);
this.btnSet.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.FixedAssetManagementCompetence, CustomAttributes.OperatingAuthority.Setting);
this.PublicFunctionRows();
}
///
/// 重置
///
///
///
void btnReset_Click(object sender, EventArgs e)
{
this.cmbtreevFixedAssetsClass.SetTextAndTag_ValueNull();
this.txtAssetsName.Text = "";
this.txtAssetsName.Tag = null;
this.txtAssetsSize.Text = "";
this.txtAssetsQuantity.Text = "";
this.txtAssetsDate.Text = "";
this.txtAssetsPerson.Text = "";
this.txtAssetsRemark.Text = "";
this.txtAssetsPrice.Text = "";
this.treevPathPhoto.Nodes.Clear();
this.pictPhoto.BackgroundImage = null;
this.btnSaveed.Text = " 保 存";
this.ControlsEnabled(true);
}
///
/// 保存
///
///
///
void btnSaveed_Click(object sender, EventArgs e)
{
if (this.btnSaveed.Text.Trim() == "编 辑")
{
this.btnSaveed.Text = " 保 存";
this.ControlsEnabled(true);
}
else
{
#region 判断资料不能为空
if (string.IsNullOrEmpty(txtAssetsName.Text))
{ MessageBoxCustom.Show("名称不能为空!"); return; }
if (string.IsNullOrEmpty(txtAssetsQuantity.Text))
{ MessageBoxCustom.Show("数量不能为空!"); return; }
if (string.IsNullOrEmpty(txtAssetsDate.DateValue))
{ MessageBoxCustom.Show("购买日期不能为空!"); return; }
if (string.IsNullOrEmpty(txtAssetsPrice.Text))
{ MessageBoxCustom.Show("购买价格不能为空!"); return; }
if (string.IsNullOrEmpty(txtAssetsPerson.Text.Trim()))
{ MessageBoxCustom.Show("保管人不能为空!"); return; }
if (string.IsNullOrEmpty(this.cmbtreevFixedAssetsClass.Text.Trim()))
{ MessageBoxCustom.Show("类别不能为空!"); return; }
#endregion
LYFZ.Model.Model_ErpFixedAssetManagement model = null;
string strWhere = "";
if (this.txtAssetsName.Tag != null)
{ strWhere = " And ID != '" + this.txtAssetsName.Tag.ToString() + "'"; }
DataTable dt = orbll.GetView_Custom("tb_ErpFixedAssetManagement", StrWhere: "Fam_Name = '" + this.txtAssetsName.Text + "'" + strWhere, ShowColumnName: "ID").Tables[0];
if (dt.Rows.Count > 0)
{
MessageBoxCustom.Show("物品名称已经存在,不能重复添加!");
this.txtAssetsName.Focus();
return;
}
DateTime StrTime = SDateTime.Now;
string StrPhotoAlbum = "";
if (this.txtAssetsName.Tag == null)
{
model = new Model.Model_ErpFixedAssetManagement();
model.Fam_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
model.Fam_CreateDatetime = StrTime;
model.Fam_CreateName = StrUserID;
}
else
{
model = fambll.GetModel(Convert.ToInt32(this.txtAssetsName.Tag));
model.Fam_UpdateDatetime = StrTime;
model.Fam_UpdateName = StrUserID;
StrPhotoAlbum = model.Fam_PhotoAlbum;
}
model.Fam_Name = txtAssetsName.Text;
model.Fam_Category = this.cmbtreevFixedAssetsClass.Tag.ToString().Trim();
model.Fam_Specification = txtAssetsSize.Text;
model.Fam_Quantity = Convert.ToInt32(txtAssetsQuantity.Text);
model.Fam_PurchasePrice = Convert.ToDecimal(txtAssetsPrice.Text);
model.Fam_BuyDatetime = Convert.ToDateTime(txtAssetsDate.DateValue);
model.Fam_Custodian = this.txtAssetsPerson.Tag.ToString();
model.Fam_Remark = txtAssetsRemark.Text;
model.Fam_PhotoAlbum = "";// PublicCodeClasses.ToHexString(PublicCodeClasses.ImageDatabytes(this.pictPhoto));
string SqlPath = "";
for (int i = 0; i < this.treevPathPhoto.Nodes.Count; i++)
{
string StrPhotoName = "";
if (!string.IsNullOrEmpty(this.treevPathPhoto.Nodes[i].Tag.ToString().Trim()))
{ StrPhotoName = new System.IO.FileInfo(this.treevPathPhoto.Nodes[i].Tag.ToString().Trim()).Name; }
else
{ StrPhotoName = new System.IO.FileInfo(this.treevPathPhoto.Nodes[i].Text.Trim()).Name; }
string StrTreevServerPathFile = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TCP_FixedAsset() + @"\" + model.ID.ToString() + @"\" + StrPhotoName;
SqlPath += StrTreevServerPathFile + "|";
if (this.treevPathPhoto.Nodes[i].ForeColor == Color.Red)
{
if (!string.IsNullOrEmpty(this.htDataFile.ToString().Trim()))
{ htDataFile[StrTreevServerPathFile + "|" + this.treevPathPhoto.Nodes[i].Tag.ToString().Trim()] = "新增"; }
else
{ htDataFile[StrTreevServerPathFile + "|"] = "新增"; }
}
}
model.Fam_PhotoPath = SqlPath;
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
backgroundWorker.ReportProgress(0, "正在连接服务器...");
foreach (DictionaryEntry de in htDataFile)
{
try
{
string ret = "";
if (de.Value.ToString().Trim() == "移除")
{ ret = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.DeleteFile(de.Key.ToString().Trim(), backgroundWorker); }
else
{
string[] StrArray = de.Key.ToString().Trim().Split('|');
if (!string.IsNullOrEmpty(StrArray[1].Trim()))
{
//ret = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.UploadFileToServer(StrArray[1].Trim(), StrArray[0].Trim(), backgroundWorker);
ret = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.UploadFileToServer(LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(StrArray[1].Trim(), 600, 800), System.Drawing.Imaging.ImageFormat.Jpeg, StrArray[0].Trim(), backgroundWorker);
}
else
{
//Image newImg = LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(new Bitmap(Img), 600, 800);
MemoryStream memoryMS = new MemoryStream();
byte[] imgbytes = PublicCodeClasses.StringToByte(StrPhotoAlbum);
memoryMS.Write(imgbytes, 0, imgbytes.Length);
ret = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.UploadFileToServer(memoryMS, StrArray[0].Trim(), backgroundWorker);
memoryMS.Close();
memoryMS.Dispose();
}
}
if (ret.IndexOf("成功") == -1)
{ MessageBoxCustom.Show(ret, backgroundWorker: backgroundWorker); }
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message, backgroundWorker: backgroundWorker); }
}
});
bool IsSaveed = false;
if (this.txtAssetsName.Tag == null)
{ IsSaveed = fambll.Add(model); }
else
{ IsSaveed = fambll.Update(model); }
if (IsSaveed)
{
this.htDataFile.Clear();
MessageBoxCustom.Show("保存成功!");
this.btnReset_Click(this, null);
this.PublicFunctionRows();
}
else
{ MessageBoxCustom.Show("保存失败!"); }
}
}
///
/// 删除
///
///
///
void btnDelete_Click(object sender, EventArgs e)
{
try
{
if (this.txtAssetsName.Tag != null)
{
if (MessageBoxCustom.Show("删除后上传的图片也会一起删除,你确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (fambll.Delete(Convert.ToInt32(this.dgvData.CurrentRow.Cells["编号"].Value)))
{
string logsContent = "删除固定资料名称:" + this.dgvData.CurrentRow.Cells["名称"].Value.ToString() + " 价格为:" + this.dgvData.CurrentRow.Cells["价格"].Value.ToString();
LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除固定资产, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
List StrPathList = new List();
for (int i = 0; i < this.treevPathPhoto.Nodes.Count; i++)
{
if (this.treevPathPhoto.Nodes[i].ForeColor == Color.Blue)
{ StrPathList.Add(this.treevPathPhoto.Nodes[i].Tag.ToString().Trim()); }
}
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
backgroundWorker.ReportProgress(0, "正在连接服务器...");
try
{
for (int i = 0; i < StrPathList.Count; i++)
{
if (!string.IsNullOrEmpty(StrPathList[i].Trim()))
{
string ret = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.DeleteFile(StrPathList[i].Trim(), backgroundWorker);
if (ret.IndexOf("成功") == -1)
{ MessageBoxCustom.Show(ret, backgroundWorker: backgroundWorker); }
}
}
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message, backgroundWorker: backgroundWorker); }
});
this.btnReset_Click(this, null);
this.ControlsEnabled(true);
this.PublicFunctionRows();
}
}
}
else if (!string.IsNullOrEmpty(this.txtAssetsName.Text.Trim()))
{ MessageBoxCustom.Show(this.txtAssetsName.Text.Trim() + ",未保存!"); }
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message); }
}
///
/// 移除相片
///
///
///
void btnRemovePhoto_Click(object sender, EventArgs e)
{
if (treevPathPhoto.Nodes.Count > 0)
{
if (this.treevPathPhoto.SelectedNode != null)
{
if (this.treevPathPhoto.SelectedNode.ForeColor == Color.Red)
{
if (MessageBoxCustom.Show("此图片已上传至服务,删除后则不能恢复回来,你确定要删除吗?", "温馨提示!", MessageBoxButtons.YesNo) == DialogResult.No)
{ return; }
this.htDataFile[this.treevPathPhoto.SelectedNode.Tag.ToString().Trim()] = "移除";
}
this.treevPathPhoto.Nodes.Remove(this.treevPathPhoto.SelectedNode);
}
else
{ MessageBoxCustom.Show("请选择你要移除的图片!"); }
}
}
///
/// 浏览
///
///
///
void btnBrowse_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "图片文件(*.jpg)|*.jpg|图片文件(*.gif)|*.gif|图片文件(*.bmp)|*.bmp|图片文件(*.png)|*.png";
openFileDialog1.FileName = "";
openFileDialog1.Multiselect = true;
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
TreeNode root = null;
string[] StrArray = openFileDialog1.FileNames;
if (StrArray.Length > 5)
{ MessageBoxCustom.Show("每个景点上传相片最多不能超过10张"); return; }
if (StrArray.Length + this.treevPathPhoto.Nodes.Count > 5)
{ MessageBoxCustom.Show("每个景点上传相片最多不能超过10张"); return; }
for (int i = 0; i < StrArray.Length; i++)
{
root = new TreeNode();
root.Text = StrArray[i].Trim();
root.Tag = StrArray[i].Trim();
root.ForeColor = Color.Red;
this.treevPathPhoto.Nodes.Add(root);
}
if (StrArray.Length == 1)
{
try
{
System.Threading.ThreadPool.QueueUserWorkItem(delegate
{
this.pictPhoto.BackgroundImage = LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(StrArray[0].Trim(), 600, 800);
});
}
catch
{ }
}
}
}
///
/// 设置
///
///
///
void btnSet_Click(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet();
frm.TypeName = "AAAAABY";
frm.Version = "Version";
if (frm.ShowDialog() == DialogResult.OK)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAABY", this.cmbtreevFixedAssetsClass);
string StrTag = "";
if (this.cmbtreevFixedAssetsClassQuerie.Tag != null)
{ StrTag = this.cmbtreevFixedAssetsClassQuerie.Tag.ToString().Trim(); }
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAABY", this.cmbtreevFixedAssetsClassQuerie, IsFirstNodeNull: true, IsFirstNodeName: "全部");
if (!string.IsNullOrEmpty(StrTag))
{ this.cmbtreevFixedAssetsClassQuerie.TagFindText(StrTag); }
}
}
Image Img = null;
///
/// 列表双击事件
///
///
///
void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
DataTable dt = fambll.GetList("ID = " + Convert.ToInt32(this.dgvData.CurrentRow.Cells["编号"].Value) + "").Tables[0];
if (dt.Rows.Count > 0)
{
this.txtAssetsName.Tag = this.dgvData.CurrentRow.Cells["编号"].Value.ToString().Trim();
this.txtAssetsName.Text = dt.Rows[0]["Fam_Name"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[0]["Fam_Category"].ToString().Trim()))
{ this.cmbtreevFixedAssetsClass.TagFindText(dt.Rows[0]["Fam_Category"].ToString().Trim()); }
else
{ this.cmbtreevFixedAssetsClass.SetTextAndTag_ValueNull(); }
this.txtAssetsQuantity.Text = dt.Rows[0]["Fam_Quantity"].ToString();
this.txtAssetsSize.Text = dt.Rows[0]["Fam_Specification"].ToString();
this.txtAssetsDate.Text = dt.Rows[0]["Fam_BuyDatetime"].ToString();
this.txtAssetsPrice.Text = dt.Rows[0]["Fam_PurchasePrice"].ToString();
this.txtAssetsRemark.Text = dt.Rows[0]["Fam_Remark"].ToString();
//this.txtAssetsPerson.TagFindText(dt.Rows[0]["Fam_Custodian"].ToString());
DataRow dtRow = this.dtUser.Rows.Find(dt.Rows[0]["Fam_Custodian"].ToString().Trim());
if (dtRow != null)
{ this.txtAssetsPerson.TagFindText(dt.Rows[0]["Fam_Custodian"].ToString()); }
else
{ this.txtAssetsPerson.TextFindTag(dt.Rows[0]["Fam_Custodian"].ToString()); }
string[] StrArray = dt.Rows[0]["Fam_PhotoPath"].ToString().Trim().Split('|');
this.treevPathPhoto.Nodes.Clear();
TreeNode root = null;
for (int i = 0; i < StrArray.Length; i++)
{
if (!string.IsNullOrEmpty(StrArray[i].Trim()))
{
root = new TreeNode();
root.Text = StrArray[i].Trim();
root.Tag = StrArray[i].Trim();
root.ForeColor = Color.Blue;
this.treevPathPhoto.Nodes.Add(root);
}
}
if (!string.IsNullOrEmpty(dt.Rows[0]["Fam_PhotoAlbum"].ToString()))
{
root = new TreeNode();
root.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TCP_FixedAsset() + "\\" + this.txtAssetsName.Text.Trim() + ".jpg";
root.Tag = "";
root.ForeColor = Color.Red;
this.treevPathPhoto.Nodes.Add(root);
pictPhoto.BeginInvoke((Action)delegate()
{
this.Img = PublicCodeClasses.GetImage(PublicCodeClasses.StringToByte(dt.Rows[0]["Fam_PhotoAlbum"].ToString()));
});
}
else
{ this.Img = null; }
this.pictPhoto.BackgroundImage = null;
this.btnSaveed.Text = " 编 辑";
this.ControlsEnabled(false);
}
}
}
///
/// 关闭
///
///
///
void btnClose_Click(object sender, EventArgs e)
{ this.Close(); }
///
/// 图片双击查看
///
///
///
void pictPhoto_Click(object sender, EventArgs e)
{
if (this.pictPhoto.BackgroundImage != null)
{
LYFZ.Software.MainBusiness.InitialSet.Product.FrmProductPic frm = new InitialSet.Product.FrmProductPic();
frm.FrmImage = this.pictPhoto.BackgroundImage;
frm.ShowDialog();
}
}
///
/// 数量限制输入
///
///
///
void txtAssetsQuantity_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
}
///
/// 价格限制输入
///
///
///
void txtAssetsPrice_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
else if (Char.IsPunctuation(e.KeyChar))
{
if (e.KeyChar == '.')
{
if (((TextBox)sender).Text.LastIndexOf('.') != -1)
{ e.Handled = true; }
}
else
{ e.Handled = true; }
}
}
///
/// 路径列表点击事件
///
///
///
void treevPathPhoto_AfterSelect(object sender, TreeViewEventArgs e)
{
if (this.treevPathPhoto.Nodes.Count > 0)
{
Image ViewImg = null;
if (this.treevPathPhoto.SelectedNode.ForeColor == Color.Red)
{
if (!string.IsNullOrEmpty(this.treevPathPhoto.SelectedNode.Tag.ToString().Trim()))
{
try
{
string Strtag = this.treevPathPhoto.SelectedNode.Tag.ToString().Trim();
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
{
ViewImg = LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(Strtag, 600, 800);
});
}
catch
{ }
}
else
{ ViewImg = this.Img; }
}
else
{
try
{
string Strtag = this.treevPathPhoto.SelectedNode.Tag.ToString().Trim();
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
{
Bitmap bmp = null;
string retmsg = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.DownloadBitmap(ref bmp, Strtag);
ViewImg = bmp;
});
}
catch
{ }
}
this.pictPhoto.BackgroundImage = ViewImg;
}
}
///
/// 固定资产选择查询
///
///
///
void cmbtreevFixedAssetsClassQuerie_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.cmbtreevFixedAssetsClassQuerie.TextFindTag(this.cmbtreevFixedAssetsClassQuerie.Text.Trim());
this.PublicFunctionRows();
}
///
/// 查询数据
///
void PublicFunctionRows()
{
this.dgvData.Rows.Clear();
string StrWhere = "";
if (this.cmbtreevFixedAssetsClassQuerie.Text.Trim() != "全部" && this.cmbtreevFixedAssetsClassQuerie.Text.Trim() != "")
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetTreeViewQueryCondition(ref StrWhere, this.cmbtreevFixedAssetsClassQuerie, StrFieldName: "Fam_Category", ConnectWord: "");
}
DataTable tbl = orbll.GetView_Custom("tb_ErpFixedAssetManagement Left Join tb_ErpSystemCategory on Sc_ClassCode = Fam_Category", StrWhere: StrWhere, ShowColumnName: "tb_ErpFixedAssetManagement.ID,Fam_Name,Sc_ClassName,Fam_Quantity,Fam_Specification,Fam_PurchasePrice,Fam_Custodian,dbo.fn_CheckDateTime(Fam_BuyDatetime) AS Fam_BuyDatetime,Fam_Remark", filedOrder: "ID DESC").Tables[0];
DataGridViewRow dgvr = null;
DataGridViewCell cell = null;
decimal decStatistic = 0;
for (int i = 0; i < tbl.Rows.Count; i++)
{
decStatistic += Convert.ToDecimal(tbl.Rows[i]["Fam_PurchasePrice"]) * Convert.ToDecimal(tbl.Rows[i]["Fam_Quantity"]);
dgvr = new DataGridViewRow();
for (int j = 0; j < tbl.Columns.Count; j++)
{
if (tbl.Columns[j].ColumnName.Trim() == "Fam_Custodian")
{
cell = new DataGridViewTextBoxCell();
DataRow dtRow = this.dtUser.Rows.Find(tbl.Rows[i][j].ToString().Trim());
if (dtRow != null)
{ cell.Value = dtRow["User_Name"].ToString(); }
else
{ cell.Value = tbl.Rows[i][j].ToString().Trim(); }
dgvr.Cells.Add(cell);
}
else
{
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i][j].ToString().Trim();
dgvr.Cells.Add(cell);
}
}
this.dgvData.Rows.Add(dgvr);
}
this.lblStatistic.Text = "资产统计:" + decStatistic;
}
///
///
///
///
void ControlsEnabled(bool IsEnabled)
{
this.cmbtreevFixedAssetsClass.Enabled = IsEnabled;
this.txtAssetsName.Enabled = IsEnabled;
this.txtAssetsDate.Enabled = IsEnabled;
this.txtAssetsQuantity.Enabled = IsEnabled;
this.txtAssetsPrice.Enabled = IsEnabled;
this.txtAssetsSize.Enabled = IsEnabled;
this.txtAssetsPerson.Enabled = IsEnabled;
this.txtAssetsRemark.Enabled = IsEnabled;
this.btnRemovePhoto.Enabled = IsEnabled;
this.btnBrowse.Enabled = IsEnabled;
this.btnDelete.Enabled = IsEnabled;
}
}
}