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;
namespace LYFZ.Software.MainBusiness.HospitalTrackingSystem
{
public partial class DispatchDoor : LYFZ.Software.UI.HospitalTrackingSystem.DispatchDoor
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
LYFZ.BLL.BLL_ErpHospitalDispatchDoor ambll = new BLL.BLL_ErpHospitalDispatchDoor();
public DispatchDoor()
{
this.Load += DispatchDoor_Load;
this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
this.btnDelete.Click += btnDelete_Click;
this.btnAdding.Click += btnAdding_Click;
this.btnUpdate.Click += btnUpdate_Click;
this.btnOK.Click += btnOK_Click;
this.btnAdding.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.AddSendSingleTask);
this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.DelSendSingleTask);
this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.UpdateSendSingleTask);
}
Model.CameraTimeTemplate currentSelectCameraTime = null;
///
/// 当前选择的档期
///
public Model.CameraTimeTemplate CurrentSelectCameraTime { get => currentSelectCameraTime; set => currentSelectCameraTime = value; }
///
/// 订单号
///
public string StrOrderNumber;
///
/// 是否保存
///
public bool IsSaveed = false;
///
/// 选择的ID
///
public int SelectID = 0;
///
/// 窗体加载
///
///
///
void DispatchDoor_Load(object sender, EventArgs e)
{
this.dgvData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtMyselfPhone);
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtHusbandPhone);
IntentionsEntered frm = new IntentionsEntered();
this.txtNumber.Text = StrOrderNumber;
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
DataTable dt = orbll.GetView_Custom("View_HospitalContact", StrWhere: "来单批号='" + StrOrderNumber + "'", ShowColumnName: "来单批号,客户姓名,本人手机,老公手机,客户区域,宝宝姓名,宝宝年龄,业务意向").Tables[0];
this.txtName.Text = dt.Rows[0]["客户姓名"].ToString();
this.txtMyselfPhone.Text = dt.Rows[0]["本人手机"].ToString();
this.txtHusbandPhone.Text = dt.Rows[0]["老公手机"].ToString();
this.txtAreas.Text = dt.Rows[0]["客户区域"].ToString();
this.txtBabyName.Text = dt.Rows[0]["宝宝姓名"].ToString();
this.txtBabyAge.Text = dt.Rows[0]["宝宝年龄"].ToString();
this.txtBusinessType.Text = dt.Rows[0]["业务意向"].ToString();
this.PublicFunctionRows();
}
///
/// 双击事件
///
///
///
void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (this.dgvData.SelectedRows != null && this.dgvData.SelectedRows.Count > 0)
{ this.btnUpdate_Click(this, e); }
// this.btnOK_Click(this, null);
}
///
/// 删除按钮
///
///
///
void btnDelete_Click(object sender, EventArgs e)
{
if (this.dgvData.Rows.Count > 0 && this.dgvData.SelectedRows.Count > 0)
{
if (this.dgvData.CurrentRow != null)
{
if (this.dgvData.SelectedRows.Count > 0)
{
if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (ambll.Delete(Convert.ToInt32(dgvData.CurrentRow.Cells["ID"].Value)))
{
this.IsSaveed = true;
MessageBoxCustom.Show("删除成功!");
this.PublicFunctionRows();
}
else
{ MessageBoxCustom.Show("删除失败!"); }
}
}
}
}
else
{ MessageBoxCustom.Show("请选择要删除的数据!"); }
}
///
/// 添加派单
///
///
///
void btnAdding_Click(object sender, EventArgs e)
{
if (this.txtNumber.Text != "")
{
AddingSendSingle frm = new AddingSendSingle();
frm.StrOrderNumber = this.StrOrderNumber;
frm.ShowDialog();
if (frm.IsSaveed)
{
this.IsSaveed = true;
this.PublicFunctionRows();
}
}
else
{ MessageBoxCustom.Show("请选择客户进行添加!"); }
}
///
/// 修改派单
///
///
///
void btnUpdate_Click(object sender, EventArgs e)
{
AddingSendSingle frm = new AddingSendSingle();
frm.TeskRow = this.dgvData.CurrentRow;
frm.ShowDialog();
if (frm.IsSaveed)
{
this.IsSaveed = true;
this.PublicFunctionRows();
}
}
///
/// 确定
///
///
///
void btnOK_Click(object sender, EventArgs e)
{
if (this.dgvData.SelectedRows.Count > 0)
{
this.IsSaveed = true;
this.SelectID = Convert.ToInt32(this.dgvData.SelectedRows[0].Cells["ID"].Value);
this.Close();
}
else
{ MessageBoxCustom.Show("请选择派单数据!"); }
}
///
/// 创建行
///
private void PublicFunctionRows()
{
string StrColumnName = "ID,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Hdr_DoorTime)) as 上门日期,Hdr_DoorPeriod as 上门时间,case when Hdr_HomeState = 0 then '未上门' else 'OK' end as 上门状态," +
"Hdr_DoorPersonOne as 上门人员1,Hdr_DoorPersonTwo as 上门人员2,Hdr_DoorPersonThree as 上门人员3,Hdr_DoorPersonFour as 上门人员4,Hdr_Vehicle as 车辆,Hdr_DispatchDoorRemark AS 备注";
DataTable dt = orbll.GetView_Custom("tb_ErpHospitalDispatchDoor", StrWhere: "Hdr_Number = '" + this.txtNumber.Text.Trim() + "'", ShowColumnName: StrColumnName).Tables[0];
this.dgvData.DataSource(dt, strHideField: "ID");
this.dgvData.ClearSelection();
}
}
}