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.Dresses.DressManagement.Rental
{
public partial class FrmDressRental : LYFZ.Software.UI.Dresses.DressManagement.Rental.FrmDressRental
{
LYFZ.BLL.BLL_ErpDressSaleRentalOrder DressSaleRentalOrderBll = new BLL.BLL_ErpDressSaleRentalOrder();
LYFZ.BLL.BLL_ErpDressFrom DressFromBll = new BLL.BLL_ErpDressFrom();
bool bl = false;
public string Dsfm_DressNumber;
public string PreselectedNumber_OK;
public FrmDressRental()
{
this.FormClosed += FrmDressRental_FormClosed;
}
void FrmDressRental_FormClosed(object sender, FormClosedEventArgs e)
{
if (bl)
{
this.DialogResult = DialogResult.OK;
}
}
#region 加载
protected override void FrmDressRental_Shown(object sender, EventArgs e)
{
try
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtCus_Telephone);
#region 部门人员绑定
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.txtDsro_CreateName, IsFirstNodeNull: true);
//LYFZ.BLL.BLL_ErpDepartment BLLerpdepartment = new BLL.BLL_ErpDepartment();
//DataTable tbl = BLLerpdepartment.GetAllList().Tables[0];
//if (tbl.Rows.Count > 0)
//{
// TreeNode root = null;
// for (int i = 0; i < tbl.Rows.Count; i++)
// {
// root = new TreeNode(tbl.Rows[i]["Dt_Name"].ToString());
// this.CreateTreeViewDepartmentUser(root.Nodes, tbl.Rows[i]["ID"].ToString());
// this.txtDsro_CreateName.TreeView.Nodes.Add(root);
// }
//}
#endregion
DataTable dt = new DataTable();
if (!string.IsNullOrEmpty(PreselectedNumber_OK))
{
#region 获取已预选
#region 隐藏
btnCusSelect.Enabled = false;
txtDsro_Amount.Text = "";
txtDsro_MortgageAmount.Text = "";
txtDsro_Remark.Text = "";
txtDsro_CreateName.Text = "";
txtDsro_CreateDateTime.Text = "";
txtDsro_TakeDressTime.Text = "";
txtDsro_ReservationBackTime.Text = "";
txtCus_Name.Text = "";
txtCus_Name.ReadOnly = true;
txtCus_Telephone.Text = "";
txtCus_Telephone.ReadOnly = true;
txtCus_QQ.Text = "";
txtCus_QQ.ReadOnly = true;
txtCus_Address.Text = "";
txtCus_Address.ReadOnly = true;
txtCus_WorkUnit.Text = "";
txtCus_WorkUnit.ReadOnly = true;
txtCus_Birthday.Text = "";
txtCus_Birthday.Enabled = false;
chkCus_BirthdayLunar.Checked = false;
chkCus_BirthdayLunar.Enabled = false;
txtCus_DayForMarriage.Text = "";
txtCus_DayForMarriage.Enabled = false;
chkCus_DayForMarriageLunar.Checked = false;
chkCus_DayForMarriageLunar.Enabled = false;
txtCus_CustomerNumber.Text = "";
txtDsro_CreateName.Enabled = false;
#endregion
#region 获取预选资料
dt = DressSaleRentalOrderBll.View_DressSaleRentalOrder(" and Dsro_Number='" + PreselectedNumber_OK + "'").Tables[0];
if (dt.Rows.Count > 0)
{
txtDsro_Number.Text = dt.Rows[0]["Dsro_Number"].ToString();
txtDsro_Amount.Text = dt.Rows[0]["Dsro_Amount"].ToString();
txtDsro_MortgageAmount.Text = dt.Rows[0]["Dsro_MortgageAmount"].ToString();
txtDsro_CreateName.TagFindText(dt.Rows[0]["Dsro_CreateName"].ToString());
txtDsro_HandledName.Text = dt.Rows[0]["经手人"].ToString();
txtDsro_CreateDateTime.Text = Convert.ToDateTime(dt.Rows[0]["Dsro_CreateDateTime"]).ToString("yyyy-MM-dd");
txtDsro_Remark.Text = dt.Rows[0]["Dsro_Remark"].ToString();
txtDsro_TakeDressTime.Text = "";
txtDsro_ReservationBackTime.Text = "";
}
#endregion
#region 获取礼服资料
if (!string.IsNullOrEmpty(Dsfm_DressNumber))
{
string[] Dsfm_DressNumbers = Dsfm_DressNumber.Split(',');
for (int t = 0; t < Dsfm_DressNumbers.Length; t++)
{
dt = DressFromBll.View_tb_ErpDressFrom(" and Dsfm_DressNumber='" + Dsfm_DressNumbers[t] + "'").Tables[0];
#region
DataGridViewRow dgvr = new DataGridViewRow();
DataGridViewCell cell = null;
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_DressNumber"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_DressName"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = "1";
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_RentPrice"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_SalePrice"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_CostPrice"].ToString().Trim();
dgvr.Cells.Add(cell);
this.dgv.Rows.Add(dgvr);
#endregion
}
dgv.ClearSelection();
}
#endregion
#region 获取客户资料
dt = new DataTable();
LYFZ.BLL.BLL_ErpCustomer CustomerBll = new BLL.BLL_ErpCustomer();
dt = CustomerBll.View_tb_ErpCustomer(" and Cus_CustomerNumber='" + DressSaleRentalOrderBll.View_DressSaleRentalOrder(" and Dsro_Number='" + PreselectedNumber_OK + "'").Tables[0].Rows[0]["Dsro_CustomerNumber"] + "'").Tables[0];
txtCus_Name.Text = dt.Rows[0]["Cus_Name"].ToString();
txtCus_Telephone.Text = dt.Rows[0]["Cus_Telephone"].ToString();
txtCus_QQ.Text = dt.Rows[0]["Cus_QQ"].ToString();
txtCus_Address.Text = dt.Rows[0]["Cus_Address"].ToString();
txtCus_WorkUnit.Text = dt.Rows[0]["Cus_WorkUnit"].ToString();
txtCus_Birthday.Text = dt.Rows[0]["Cus_Birthday"].ToString();
string Cus_BirthdayLunar = dt.Rows[0]["Cus_BirthdayLunar"].ToString();
if (Cus_BirthdayLunar.ToString() == "1")
{
chkCus_BirthdayLunar.Checked = true;
}
txtCus_DayForMarriage.Text = dt.Rows[0]["Cus_DayForMarriage"].ToString();
string Cus_DayForMarriageLunar = dt.Rows[0]["Cus_DayForMarriageLunar"].ToString();
if (Cus_DayForMarriageLunar.ToString() == "1")
{ chkCus_DayForMarriageLunar.Checked = true; }
txtCus_CustomerNumber.Text = dt.Rows[0]["Cus_CustomerNumber"].ToString();
#endregion
#endregion
}
else
{
#region 无预选
txtDsro_HandledName.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
txtDsro_CreateDateTime.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyy-MM-dd");
#region 获取单号
BindDsro_Number();
#endregion
#region 获取礼服资料
if (!string.IsNullOrEmpty(Dsfm_DressNumber))
{
string[] Dsfm_DressNumbers = Dsfm_DressNumber.Split(',');
for (int t = 0; t < Dsfm_DressNumbers.Length; t++)
{
dt = DressFromBll.View_tb_ErpDressFrom(" and Dsfm_DressNumber='" + Dsfm_DressNumbers[t] + "'").Tables[0];
#region
DataGridViewRow dgvr = new DataGridViewRow();
DataGridViewCell cell = null;
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_DressNumber"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_DressName"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = "1";
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_RentPrice"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_SalePrice"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = dt.Rows[0]["Dsfm_CostPrice"].ToString().Trim();
dgvr.Cells.Add(cell);
this.dgv.Rows.Add(dgvr);
#endregion
}
dgv.ClearSelection();
}
#endregion
#endregion
}
}
catch (Exception ex)
{
MessageBoxCustom.Show(ex.Message);
}
}
#region 获取礼服订单单号
///
/// 获取礼服订单单号
///
public void BindDsro_Number()
{
DataTable dt = new DataTable();
//获取最大编号
LYFZ.BLL.BLL_ErpDressSaleRentalOrder DressSaleRentalOrderbll = new BLL.BLL_ErpDressSaleRentalOrder();
dt = DressSaleRentalOrderbll.GetAllList().Tables[0];
if (dt.Rows.Count > 0)
{
int Count = Convert.ToInt32(DressSaleRentalOrderbll.Get_Max_Dsro_Number());
this.txtDsro_Number.Text = "LFDH00" + Convert.ToInt32(Count + 1);
}
else
{
this.txtDsro_Number.Text = "LFDH001";
}
}
#endregion
#endregion
#region dgv事件
protected override void dgv_Click(object sender, EventArgs e)
{
if (dgv.Rows.Count > 0)
{
LYFZ.BLL.BLL_ErpDressFrom DressFromBll = new BLL.BLL_ErpDressFrom();
DataTable dt = new DataTable();
string Dsfm_DressNumber = dgv.CurrentRow.Cells["Dsfm_DressNumber"].Value.ToString();
dt = DressFromBll.View_tb_ErpDressFrom(" and Dsfm_DressNumber='" + Dsfm_DressNumber + "'").Tables[0];
if (dt.Rows.Count > 0)
{
string dressFromPath = BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + dt.Rows[0]["Dsfm_PicturePath"];
if (System.IO.File.Exists(dressFromPath))
{
picDsfm_PicturePath.Image = Image.FromFile(dressFromPath);
}
}
}
}
#endregion
#region 保存
protected override void btnSave_Click(object sender, EventArgs e)
{
try
{
LYFZ.BLL.BLL_ErpOrder Orderbll = new LYFZ.BLL.BLL_ErpOrder();
LYFZ.BLL.BLL_ErpDressSaleRentalOrder DressSaleRentalOrderBll = new BLL.BLL_ErpDressSaleRentalOrder();
LYFZ.Model.Model_ErpDressSaleRentalOrder DressSaleRentalOrderModel = new Model.Model_ErpDressSaleRentalOrder();
LYFZ.BLL.BLL_ErpDressSaleRentalDetail DressSaleRentalDetailBll = new BLL.BLL_ErpDressSaleRentalDetail();
LYFZ.Model.Model_ErpDressSaleRentalDetail DressSaleRentalDetailModel = new Model.Model_ErpDressSaleRentalDetail();
LYFZ.BLL.BLL_ErpDressFrom DressFromBll = new BLL.BLL_ErpDressFrom();
LYFZ.Model.Model_ErpDressFrom DressFromModel = null;
LYFZ.BLL.BLL_ErpSystemConfigure SystemConfigureBll = new BLL.BLL_ErpSystemConfigure();
string ty = "";
if (string.IsNullOrEmpty(txtDsro_TakeDressTime.DateValue))
{
MessageBoxCustom.Show("取衣时间不能为空!");
return;
}
#region 判断礼服是否撞期
if (dgv.Rows.Count > 0)
{
DataTable dt_DressSaleRentalDetail = Orderbll.GetView_Custom("View_DressSaleRentalDetail", StrWhere: "Dsro_Type='0' and Dsrd_BackStatus='3'", ShowColumnName: "Id,Dsrd_Number,Dsrd_DressNumber,Dsrd_DressName,Dsrd_SaleRentalQuantity,Dsrd_CostPrice,Dsrd_SalePrice,Dsrd_BackTime,Dsrd_BackStatus,Dsrd_BackRemark,Dsrd_CreateDateTime,Dsrd_CreateName,Dsrd_UpdateDateTime,Dsrd_UpdateName,Dsro_Number,Dsro_Type,Dsro_Amount,Dsro_MortgageAmount,Dsro_CustomerNumber,Dsro_TakeDressTime,Dsro_ReservationBackTime,Dsro_Remark,Dsro_CreateDateTime,Dsro_CreateName,Dsro_UpdateDateTime,Dsro_UpdateName,Cus_Name,还衣天数,还衣天数取衣日期,还衣天数加还衣日期,Dsfm_RentPrice").Tables[0];
for (int i = 0; i < dgv.Rows.Count; i++)
{
//选择取衣时间
DateTime TakeClothesTime = Convert.ToDateTime(txtDsro_TakeDressTime.DateValue);
//礼服编号
string Dsfm_DressNumber = dgv.Rows[i].Cells["Dsfm_DressNumber"].Value.ToString();
DataRow[] row_DSRD = dt_DressSaleRentalDetail.Select(" Dsrd_DressNumber='" + Dsfm_DressNumber + "' ");
if (row_DSRD.Length > 0)
{
for (int t = 0; t < row_DSRD.Length; t++)
{
DateTime StarTime = Convert.ToDateTime(row_DSRD[t]["还衣天数取衣日期"]);
DateTime StarEnd = Convert.ToDateTime(row_DSRD[t]["还衣天数加还衣日期"]);
if (TakeClothesTime >= StarTime && TakeClothesTime <= StarEnd)
{
ty = "1";
}
}
if (ty == "1")
{
MessageBoxCustom.Show("(礼服编号:" + Dsfm_DressNumber + " " + " 礼服名称:" + dgv.Rows[i].Cells["Dsfm_DressName"].Value.ToString() + ") 已经撞期,无法租售");
return;
}
}
}
}
#endregion
#region 出租
if (radRent.Checked == true)
{
#region 判断输入框不能为空
if (string.IsNullOrEmpty(txtDsro_Number.Text))
{
MessageBoxCustom.Show("单号不能为空!");
return;
}
if (dgv.Rows.Count == 0)
{
MessageBoxCustom.Show("礼服资料不能为空!请选择礼服!");
return;
}
if (string.IsNullOrEmpty(txtDsro_Amount.Text))
{
MessageBoxCustom.Show("金额不能为空!");
return;
}
if (string.IsNullOrEmpty(txtDsro_MortgageAmount.Text))
{
MessageBoxCustom.Show("押金不能为空!");
return;
}
if (string.IsNullOrEmpty(txtDsro_CreateName.Text.Trim()))
{
MessageBoxCustom.Show("销售人员不能为空!");
return;
}
if (string.IsNullOrEmpty(txtCus_Name.Text))
{
MessageBoxCustom.Show("客户名称不能为空!");
return;
}
if (string.IsNullOrEmpty(txtCus_Telephone.Text))
{
MessageBoxCustom.Show("客户电话不能为空!");
return;
}
if (string.IsNullOrEmpty(txtDsro_ReservationBackTime.DateValue))
{
MessageBoxCustom.Show("还回时间不能为空!");
return;
}
if (!string.IsNullOrEmpty(txtDsro_TakeDressTime.DateValue) && !string.IsNullOrEmpty(txtDsro_ReservationBackTime.DateValue))
{
if (Convert.ToDateTime(txtDsro_TakeDressTime.DateValue) > Convert.ToDateTime(txtDsro_ReservationBackTime.DateValue))
{
MessageBoxCustom.Show("取衣时间必须小于还衣时间!");
return;
}
}
int intMasse = this.txtCus_Birthday.CheckDateValue(this.txtCus_Birthday, chkCus_BirthdayLunar);
if (intMasse == 1) { MessageBoxCustom.Show("生日日期日期格式输入错误"); return; }
else if (intMasse == 2)
{ MessageBoxCustom.Show("生日日期:" + this.txtCus_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"); return; }
intMasse = this.txtCus_DayForMarriage.CheckDateValue(this.txtCus_DayForMarriage, chkCus_DayForMarriageLunar);
if (intMasse == 1) { MessageBoxCustom.Show("婚期日期日期格式输入错误"); return; }
else if (intMasse == 2)
{ MessageBoxCustom.Show("婚期日期:" + this.txtCus_DayForMarriage.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"); return; }
#endregion
#region 出租
if (!string.IsNullOrEmpty(PreselectedNumber_OK))
{
DataTable dt = DressSaleRentalOrderBll.GetList(" Dsro_Number='" + PreselectedNumber_OK + "'").Tables[0];
DressSaleRentalOrderModel = DressSaleRentalOrderBll.GetModel(Convert.ToInt32(dt.Rows[0]["ID"]));
#region 修改礼服租售订单表
DressSaleRentalOrderModel.Dsro_Type = "0";
DressSaleRentalOrderModel.Dsro_Amount = Convert.ToDecimal(txtDsro_Amount.Text == "" ? "0.00" : txtDsro_Amount.Text);
DressSaleRentalOrderModel.Dsro_MortgageAmount = Convert.ToDecimal(txtDsro_MortgageAmount.Text == "" ? "0.00" : txtDsro_MortgageAmount.Text);
DressSaleRentalOrderModel.Dsro_TakeDressTime = Convert.ToDateTime(txtDsro_TakeDressTime.DateValue.ToString());
DressSaleRentalOrderModel.Dsro_ReservationBackTime = Convert.ToDateTime(txtDsro_ReservationBackTime.DateValue); ;
DressSaleRentalOrderModel.Dsro_Remark = txtDsro_Remark.Text.Trim();
DressSaleRentalOrderModel.Dsro_UpdateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
DressSaleRentalOrderModel.Dsro_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
DressSaleRentalOrderBll.Update(DressSaleRentalOrderModel);
#endregion
MessageBoxCustom.Show("保存成功!");
this.Close();
}
else
{
#region 增加礼服租售订单表
DressSaleRentalOrderModel.Dsro_Number = txtDsro_Number.Text.Trim();
DressSaleRentalOrderModel.Dsro_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
DressSaleRentalOrderModel.Dsro_Type = "0";
DressSaleRentalOrderModel.Dsro_Amount = Convert.ToDecimal(txtDsro_Amount.Text == "" ? "0.00" : txtDsro_Amount.Text);
DressSaleRentalOrderModel.Dsro_MortgageAmount = Convert.ToDecimal(txtDsro_MortgageAmount.Text == "" ? "0.00" : txtDsro_MortgageAmount.Text);
DressSaleRentalOrderModel.Dsro_TakeDressTime = Convert.ToDateTime(txtDsro_TakeDressTime.DateValue.ToString());
DressSaleRentalOrderModel.Dsro_ReservationBackTime = Convert.ToDateTime(txtDsro_ReservationBackTime.DateValue); ;
DressSaleRentalOrderModel.Dsro_Remark = txtDsro_Remark.Text.Trim();
DressSaleRentalOrderModel.Dsro_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
DressSaleRentalOrderModel.Dsro_CreateName = txtDsro_CreateName.Tag.ToString();
DressSaleRentalOrderModel.Dsro_HandledName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
#region 增加客户编号
if (txtCus_Name.ReadOnly == true)
{
DressSaleRentalOrderModel.Dsro_CustomerNumber = txtCus_CustomerNumber.Text.Trim();
}
else
{
LYFZ.Model.Model_ErpCustomer model = new Model.Model_ErpCustomer();
LYFZ.BLL.BLL_ErpCustomer bll = new BLL.BLL_ErpCustomer();
#region 增加
#region 手机存在
if (!string.IsNullOrEmpty(txtCus_Telephone.Text))
{
if (bll.Exists("Cus_Telephone", txtCus_Telephone.Text) == true)
{
MessageBoxCustom.Show("客户手机已经存在");
return;
}
}
#endregion
model.Cus_CustomerNumber = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMMddHHmmssfff") + "1";//获取新编号
model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
model.Cus_CustomizeNumber = "";
model.Cus_Type = "订单客户";
model.Cus_ServiceType = "Clothing";
model.Cus_Name = this.txtCus_Name.Text.ToString().Trim();
model.Cus_Telephone = this.txtCus_Telephone.Text.ToString().Trim();
model.Cus_QQ = this.txtCus_QQ.Text.ToString().Trim();
model.Cus_Address = this.txtCus_Address.Text.ToString().Trim();
model.Cus_WorkUnit = this.txtCus_WorkUnit.Text.ToString().Trim();
model.Cus_Birthday = txtCus_Birthday.StrValue.Trim();
if (chkCus_BirthdayLunar.Checked == true)
{
model.Cus_BirthdayLunar = "1";
}
else { model.Cus_BirthdayLunar = "0"; }
model.Cus_DayForMarriage = txtCus_DayForMarriage.StrValue.ToString();
if (chkCus_DayForMarriageLunar.Checked == true)
{
model.Cus_DayForMarriageLunar = "1";
}
else
{
model.Cus_DayForMarriageLunar = "0";
}
model.Cus_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
bll.Add(model);
#endregion
DressSaleRentalOrderModel.Dsro_CustomerNumber = model.Cus_CustomerNumber;
}
#endregion
DressSaleRentalOrderBll.Add(DressSaleRentalOrderModel);
#endregion
#region 租售礼服详情表
if (dgv.Rows.Count > 0)
{
for (int i = 0; i < dgv.Rows.Count; i++)
{
DressSaleRentalDetailModel.Dsrd_Number = DressSaleRentalOrderModel.Dsro_Number;
DressSaleRentalDetailModel.Dsrd_DressNumber = dgv.Rows[i].Cells["Dsfm_DressNumber"].Value.ToString();
DressSaleRentalDetailModel.Dsrd_DressName = dgv.Rows[i].Cells["Dsfm_DressName"].Value.ToString();
DressSaleRentalDetailModel.Dsrd_SaleRentalQuantity = Convert.ToInt32(dgv.Rows[i].Cells["Dsfm_DressQuantity"].Value);
DressSaleRentalDetailModel.Dsrd_CostPrice = Convert.ToDecimal(dgv.Rows[i].Cells["Dsfm_CostPrice"].Value);
DressSaleRentalDetailModel.Dsrd_SalePrice = Convert.ToDecimal(dgv.Rows[i].Cells["Dsfm_SalePrice"].Value);
DressSaleRentalDetailModel.Dsrd_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
DressSaleRentalDetailModel.Dsrd_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
DressSaleRentalDetailModel.Dsrd_BackTime = Convert.ToDateTime(null);
DressSaleRentalDetailModel.Dsrd_BackStatus = "3";
DressSaleRentalDetailModel.Dsrd_BackRemark = "";
DressSaleRentalDetailBll.Add(DressSaleRentalDetailModel);
}
}
#endregion
MessageBoxCustom.Show("保存成功!");
this.Close();
}
#endregion
}
#endregion
#region 出售
if (radSell.Checked == true)
{
#region 判断输入框不能为空
if (string.IsNullOrEmpty(txtDsro_Number.Text))
{
MessageBoxCustom.Show("单号不能为空!");
return;
}
if (dgv.Rows.Count == 0)
{
MessageBoxCustom.Show("礼服资料不能为空!请选择礼服!");
return;
}
if (string.IsNullOrEmpty(txtDsro_Amount.Text))
{
MessageBoxCustom.Show("金额不能为空!");
return;
}
if (string.IsNullOrEmpty(txtDsro_CreateName.Text.Trim()))
{
MessageBoxCustom.Show("销售人员不能为空!");
return;
}
if (string.IsNullOrEmpty(txtCus_Name.Text))
{
MessageBoxCustom.Show("客户名称不能为空!");
return;
}
if (string.IsNullOrEmpty(txtCus_Telephone.Text))
{
MessageBoxCustom.Show("客户电话不能为空!");
return;
}
int intMasse = this.txtCus_Birthday.CheckDateValue(this.txtCus_Birthday, chkCus_BirthdayLunar);
if (intMasse == 1) { MessageBoxCustom.Show("生日日期日期格式输入错误"); return; }
else if (intMasse == 2)
{ MessageBoxCustom.Show("生日日期:" + this.txtCus_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"); return; }
intMasse = this.txtCus_DayForMarriage.CheckDateValue(this.txtCus_DayForMarriage, chkCus_DayForMarriageLunar);
if (intMasse == 1) { MessageBoxCustom.Show("婚期日期日期格式输入错误"); return; }
else if (intMasse == 2)
{ MessageBoxCustom.Show("婚期日期:" + this.txtCus_DayForMarriage.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"); return; }
#endregion
#region 出售
if (!string.IsNullOrEmpty(PreselectedNumber_OK))
{
DataTable dt = DressSaleRentalOrderBll.GetList(" Dsro_Number='" + PreselectedNumber_OK + "'").Tables[0];
DressSaleRentalOrderModel = DressSaleRentalOrderBll.GetModel(Convert.ToInt32(dt.Rows[0]["ID"]));
#region 修改礼服租售订单表
DressSaleRentalOrderModel.Dsro_Type = "1";
DressSaleRentalOrderModel.Dsro_Amount = Convert.ToDecimal(txtDsro_Amount.Text == "" ? "0.00" : txtDsro_Amount.Text);
DressSaleRentalOrderModel.Dsro_MortgageAmount = 0;
DressSaleRentalOrderModel.Dsro_TakeDressTime = Convert.ToDateTime(txtDsro_TakeDressTime.DateValue.ToString());
DressSaleRentalOrderModel.Dsro_ReservationBackTime = Convert.ToDateTime(null);
DressSaleRentalOrderModel.Dsro_Remark = txtDsro_Remark.Text.Trim();
DressSaleRentalOrderModel.Dsro_UpdateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
DressSaleRentalOrderModel.Dsro_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
DressSaleRentalOrderBll.Update(DressSaleRentalOrderModel);
#endregion
#region 修改礼服详情表
int i = DressSaleRentalOrderBll.Updatefl(PreselectedNumber_OK);
#endregion
#region 礼服出售减库存
dt = new DataTable();
dt = DressSaleRentalDetailBll.GetList("Dsrd_Number='" + PreselectedNumber_OK + "'").Tables[0];
if (dt.Rows.Count > 0)
{
for (int t = 0; t < dt.Rows.Count; t++)
{
int count2 = Convert.ToInt32(dt.Rows[t]["Dsrd_SaleRentalQuantity"]);
DataTable dt_df = DressFromBll.GetList("Dsfm_DressNumber='" + dt.Rows[t]["Dsrd_DressNumber"] + "'").Tables[0];
int count1 = Convert.ToInt32(dt_df.Rows[0]["Dsfm_DressQuantity"]);
DressFromModel = DressFromBll.GetModel(Convert.ToInt32(dt_df.Rows[0]["ID"]));
DressFromModel.Dsfm_DressQuantity = Convert.ToInt32(count1) - Convert.ToInt32(count2);
DressFromBll.Update(DressFromModel);
}
}
#endregion
MessageBoxCustom.Show("保存成功!");
this.Close();
}
else
{
#region 增加礼服租售订单表
DressSaleRentalOrderModel.Dsro_Number = txtDsro_Number.Text.Trim();
DressSaleRentalOrderModel.Dsro_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
DressSaleRentalOrderModel.Dsro_Type = "1";
DressSaleRentalOrderModel.Dsro_Amount = Convert.ToDecimal(txtDsro_Amount.Text == "" ? "0.00" : txtDsro_Amount.Text);
DressSaleRentalOrderModel.Dsro_MortgageAmount = 0;
DressSaleRentalOrderModel.Dsro_TakeDressTime = Convert.ToDateTime(txtDsro_TakeDressTime.DateValue.ToString());
DressSaleRentalOrderModel.Dsro_ReservationBackTime = Convert.ToDateTime(null);
DressSaleRentalOrderModel.Dsro_Remark = txtDsro_Remark.Text.Trim();
DressSaleRentalOrderModel.Dsro_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
DressSaleRentalOrderModel.Dsro_CreateName = txtDsro_CreateName.Tag.ToString();
DressSaleRentalOrderModel.Dsro_HandledName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
#region 增加客户编号
if (txtCus_Name.ReadOnly == true)
{
DressSaleRentalOrderModel.Dsro_CustomerNumber = txtCus_CustomerNumber.Text.Trim();
}
else
{
LYFZ.Model.Model_ErpCustomer model = new Model.Model_ErpCustomer();
LYFZ.BLL.BLL_ErpCustomer bll = new BLL.BLL_ErpCustomer();
#region 增加
#region 手机存在
if (!string.IsNullOrEmpty(txtCus_Telephone.Text))
{
if (bll.Exists("Cus_Telephone", txtCus_Telephone.Text) == true)
{
MessageBoxCustom.Show("客户手机已经存在");
return;
}
}
#endregion
model.Cus_CustomerNumber = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMMddHHmmssfff") + "1";//获取新编号
model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
model.Cus_CustomizeNumber = "";
model.Cus_Type = "订单客户";
model.Cus_ServiceType = "Clothing";
model.Cus_Name = this.txtCus_Name.Text.ToString().Trim();
model.Cus_Telephone = this.txtCus_Telephone.Text.ToString().Trim();
model.Cus_QQ = this.txtCus_QQ.Text.ToString().Trim();
model.Cus_Address = this.txtCus_Address.Text.ToString().Trim();
model.Cus_WorkUnit = this.txtCus_WorkUnit.Text.ToString().Trim();
model.Cus_Birthday = txtCus_Birthday.StrValue.Trim();
if (chkCus_BirthdayLunar.Checked == true)
{
model.Cus_BirthdayLunar = "1";
}
else { model.Cus_BirthdayLunar = "0"; }
model.Cus_DayForMarriage = txtCus_DayForMarriage.StrValue.Trim();
if (chkCus_DayForMarriageLunar.Checked == true)
{
model.Cus_DayForMarriageLunar = "1";
}
else
{
model.Cus_DayForMarriageLunar = "0";
}
model.Cus_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
bll.Add(model);
#endregion
DressSaleRentalOrderModel.Dsro_CustomerNumber = model.Cus_CustomerNumber;
}
#endregion
DressSaleRentalOrderBll.Add(DressSaleRentalOrderModel);
#endregion
#region 租售礼服详情表
if (dgv.Rows.Count > 0)
{
for (int i = 0; i < dgv.Rows.Count; i++)
{
DressSaleRentalDetailModel.Dsrd_Number = DressSaleRentalOrderModel.Dsro_Number;
DressSaleRentalDetailModel.Dsrd_DressNumber = dgv.Rows[i].Cells["Dsfm_DressNumber"].Value.ToString();
DressSaleRentalDetailModel.Dsrd_DressName = dgv.Rows[i].Cells["Dsfm_DressName"].Value.ToString();
DressSaleRentalDetailModel.Dsrd_SaleRentalQuantity = Convert.ToInt32(dgv.Rows[i].Cells["Dsfm_DressQuantity"].Value);
DressSaleRentalDetailModel.Dsrd_CostPrice = Convert.ToDecimal(dgv.Rows[i].Cells["Dsfm_CostPrice"].Value);
DressSaleRentalDetailModel.Dsrd_SalePrice = Convert.ToDecimal(dgv.Rows[i].Cells["Dsfm_SalePrice"].Value);
DressSaleRentalDetailModel.Dsrd_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
DressSaleRentalDetailModel.Dsrd_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
DressSaleRentalDetailModel.Dsrd_BackTime = Convert.ToDateTime(null);
DressSaleRentalDetailModel.Dsrd_BackStatus = "";
DressSaleRentalDetailModel.Dsrd_BackRemark = "";
DressSaleRentalDetailBll.Add(DressSaleRentalDetailModel);
}
}
#endregion
#region 礼服出售减库存
DataTable dt = new DataTable();
dt = DressSaleRentalDetailBll.GetList("Dsrd_Number='" + txtDsro_Number.Text.Trim() + "'").Tables[0];
if (dt.Rows.Count > 0)
{
for (int t = 0; t < dt.Rows.Count; t++)
{
int count2 = Convert.ToInt32(dt.Rows[t]["Dsrd_SaleRentalQuantity"]);
DataTable dt_df = DressFromBll.GetList("Dsfm_DressNumber='" + dt.Rows[t]["Dsrd_DressNumber"] + "'").Tables[0];
int count1 = Convert.ToInt32(dt_df.Rows[0]["Dsfm_DressQuantity"]);
DressFromModel = DressFromBll.GetModel(Convert.ToInt32(dt_df.Rows[0]["ID"]));
DressFromModel.Dsfm_DressQuantity = Convert.ToInt32(count1) - Convert.ToInt32(count2);
DressFromBll.Update(DressFromModel);
}
}
#endregion
MessageBoxCustom.Show("保存成功!");
this.Close();
}
#endregion
}
#endregion
bl = true;
LYFZ.Software.MainBusiness.Dresses.DressManagement.Rental.FrmPayment set = new FrmPayment();
set.StrOrderNumber = txtDsro_Number.Text;
set.ShowDialog();
}
catch (Exception ex)
{
MessageBoxCustom.Show(ex.Message);
}
}
#endregion
#region 客户选择
protected override void btnCusSelect_Click(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.Dresses.DressManagement.FrmCusSelect set = new FrmCusSelect();
set.ShowDialog();
if (!string.IsNullOrEmpty(set.StrClientNumber))
{
LYFZ.BLL.BLL_ErpCustomer CustomerBll = new BLL.BLL_ErpCustomer();
DataTable dt = CustomerBll.View_tb_ErpCustomer(" and Cus_CustomerNumber='" + set.StrClientNumber + "'").Tables[0];
if (dt.Rows.Count > 0)
{
txtCus_Name.Text = "";
txtCus_Name.ReadOnly = true;
txtCus_Telephone.Text = "";
txtCus_Telephone.ReadOnly = true;
txtCus_QQ.Text = "";
txtCus_QQ.ReadOnly = true;
txtCus_Address.Text = "";
txtCus_Address.ReadOnly = true;
txtCus_WorkUnit.Text = "";
txtCus_WorkUnit.ReadOnly = true;
txtCus_Birthday.Text = "";
txtCus_Birthday.Enabled = false;
chkCus_BirthdayLunar.Checked = false;
chkCus_BirthdayLunar.Enabled = false;
txtCus_DayForMarriage.Text = "";
txtCus_DayForMarriage.Enabled = false;
chkCus_DayForMarriageLunar.Checked = false;
chkCus_DayForMarriageLunar.Enabled = false;
txtCus_CustomerNumber.Text = "";
txtCus_Name.Text = dt.Rows[0]["Cus_Name"].ToString();
txtCus_Telephone.Text = dt.Rows[0]["Cus_Telephone"].ToString();
txtCus_QQ.Text = dt.Rows[0]["Cus_QQ"].ToString();
txtCus_Address.Text = dt.Rows[0]["Cus_Address"].ToString();
txtCus_WorkUnit.Text = dt.Rows[0]["Cus_WorkUnit"].ToString();
txtCus_Birthday.Text = dt.Rows[0]["Cus_Birthday"].ToString();
string Cus_BirthdayLunar = dt.Rows[0]["Cus_BirthdayLunar"].ToString();
if (Cus_BirthdayLunar.ToString() == "1")
{
chkCus_BirthdayLunar.Checked = true;
}
txtCus_DayForMarriage.Text = dt.Rows[0]["Cus_DayForMarriage"].ToString();
string Cus_DayForMarriageLunar = dt.Rows[0]["Cus_DayForMarriageLunar"].ToString();
if (Cus_DayForMarriageLunar.ToString() == "1")
{ chkCus_DayForMarriageLunar.Checked = true; }
txtCus_CustomerNumber.Text = dt.Rows[0]["Cus_CustomerNumber"].ToString();
}
}
}
#endregion
#region 关闭
protected override void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
#endregion
#region 清空
protected override void btnClear_Click(object sender, EventArgs e)
{
txtDsro_Remark.Text = "";
btnCusSelect.Enabled = true;
txtCus_Name.Text = "";
txtCus_Name.ReadOnly = false;
txtCus_Telephone.Text = "";
txtCus_Telephone.ReadOnly = false;
txtCus_QQ.Text = "";
txtCus_QQ.ReadOnly = false;
txtCus_Address.Text = "";
txtCus_Address.ReadOnly = false;
txtCus_WorkUnit.Text = "";
txtCus_WorkUnit.ReadOnly = false;
txtCus_Birthday.Text = "";
txtCus_Birthday.Enabled = true;
chkCus_BirthdayLunar.Checked = false;
chkCus_BirthdayLunar.Enabled = true;
txtCus_DayForMarriage.Text = "";
txtCus_DayForMarriage.Enabled = true;
chkCus_DayForMarriageLunar.Checked = false;
chkCus_DayForMarriageLunar.Enabled = true;
txtCus_CustomerNumber.Text = "";
BindDsro_Number();
txtDsro_CreateName.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
txtDsro_CreateDateTime.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString();
txtDsro_CreateName.Enabled = true;
}
#endregion
#region 单选按钮
protected override void radSell_Click(object sender, EventArgs e)
{
lblDsro_MortgageAmount.Visible = false;
txtDsro_MortgageAmount.Visible = false;
lbltxtDsro_ReservationBackTime.Visible = false;
txtDsro_ReservationBackTime.Visible = false;
}
protected override void radRent_Click(object sender, EventArgs e)
{
txtDsro_MortgageAmount.Text = "";
txtDsro_ReservationBackTime.Text = "";
lblDsro_MortgageAmount.Visible = true;
txtDsro_MortgageAmount.Visible = true;
lbltxtDsro_ReservationBackTime.Visible = true;
txtDsro_ReservationBackTime.Visible = true;
}
#endregion
#region 输入框设置
protected override void txtCus_Telephone_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{
e.Handled = true;
}
}
protected override void txtDsro_MortgageAmount_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
{
e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
}
else if (Char.IsPunctuation(e.KeyChar))
{
if (e.KeyChar == '.')
{
if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
{
e.Handled = true;
}
}
else
{
e.Handled = true;
}
}
}
protected override void txtDsro_Amount_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
{
e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
}
else if (Char.IsPunctuation(e.KeyChar))
{
if (e.KeyChar == '.')
{
if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
{
e.Handled = true;
}
}
else
{
e.Handled = true;
}
}
}
#endregion
#region 时间输入框设置
protected override void txtDsro_ReservationBackTime_Leave(object sender, EventArgs e)
{
if (this.txtDsro_ReservationBackTime.Text.Trim() != "")
{
if (LYFZ.Command.Command_Validate.IsDateTime(this.txtDsro_ReservationBackTime.Text.Trim()) == false)
{
this.txtDsro_ReservationBackTime.Text = "";
MessageBoxCustom.Show("还回时间格式输入错误");
txtDsro_ReservationBackTime.Text = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd");
}
}
}
protected override void txtDsro_ReservationBackTime_Enter(object sender, EventArgs e)
{
if (this.txtDsro_ReservationBackTime.Text == "")
{
txtDsro_ReservationBackTime.Text = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd");
}
}
protected override void txtDsro_TakeDressTime_Leave(object sender, EventArgs e)
{
if (this.txtDsro_TakeDressTime.Text.Trim() != "")
{
if (LYFZ.Command.Command_Validate.IsDateTime(this.txtDsro_TakeDressTime.Text.Trim()) == false)
{
this.txtDsro_TakeDressTime.Text = "";
MessageBoxCustom.Show("取衣时间格式输入错误");
txtDsro_TakeDressTime.Text = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd");
}
}
}
protected override void txtDsro_TakeDressTime_Enter(object sender, EventArgs e)
{
if (this.txtDsro_TakeDressTime.Text == "")
{
txtDsro_TakeDressTime.Text = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime()).ToString("yyyy-MM-dd");
}
}
#endregion
#region 绑定第二级人员
///
/// 绑定第二级人员
///
/// TreeView的节点集合
/// 数据源
///
private void CreateTreeViewDepartmentUser(TreeNodeCollection nodes, string ClassCode)
{
if (ClassCode != "")
{
LYFZ.BLL.BLL_ErpUser BLLerpuser = new BLL.BLL_ErpUser();
DataTable tbl = BLLerpuser.GetList("User_Department='" + ClassCode + "' and id!='1' and User_Status='在职'").Tables[0];
if (tbl.Rows.Count > 0)
{
TreeNode node;
for (int i = 0; i < tbl.Rows.Count; i++)
{
node = new TreeNode();
node.Text = tbl.Rows[i]["User_Name"].ToString();
node.Tag = tbl.Rows[i]["User_EmployeeID"].ToString();
node.Name = tbl.Rows[i]["User_Account"].ToString();
nodes.Add(node);
}
}
}
}
#endregion
}
}