药品信息页面添加校验及药品基数信息
This commit is contained in:
parent
eed6d5d0e9
commit
5f990b7fa4
|
@ -15,16 +15,16 @@ namespace DM_Weight.Models
|
|||
public class DrugBase:BindableBase
|
||||
{
|
||||
private int _baseId = 0;
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
||||
[SugarColumn(ColumnName = "baseid", IsPrimaryKey = true)]
|
||||
public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } }
|
||||
private long _drugId = 0;
|
||||
private string _drugId;
|
||||
[SugarColumn(ColumnName = "drugid")]
|
||||
public long DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } }
|
||||
public string DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } }
|
||||
private string _machineId = "";
|
||||
[SugarColumn(ColumnName = "machine_id")]
|
||||
public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } }
|
||||
private int _baseQuantity = 0;
|
||||
[SugarColumn(ColumnName = "base_quantity")]
|
||||
[SugarColumn(ColumnName = "baseQuantity")]
|
||||
public int BaseQuantity { get=>_baseQuantity; set{ SetProperty(ref _baseQuantity, value); } }
|
||||
|
||||
}
|
||||
|
|
|
@ -329,10 +329,10 @@ namespace DM_Weight.ViewModels
|
|||
ac.invoice_no as InvoiceNo, ac.manu_no as ManuNo,ac.eff_date as EffDate,di.drug_id,di.drug_name as DrugName,di.drug_spec as DrugSpec,di.manufactory as Manufactory,di.pack_unit,di.dosage,u1.user_name as OperatorName,u2.user_name as ReviewerName
|
||||
FROM account_book_g2 ac left join drug_info di on ac.drug_id=di.drug_id left join user_list u1 on ac.user_id1=u1.id left join user_list u2 on ac.user_id2=u2.id
|
||||
WHERE ac.machine_id='{p_machine_id}' and create_time>'{p_startDate}' AND create_time<'{p_endDate}' ";
|
||||
if (!string.IsNullOrEmpty(drug_id))
|
||||
{
|
||||
SQL += " AND ac.drug_id='" + drug_id + "' ";
|
||||
}
|
||||
//if (!string.IsNullOrEmpty(drug_id))
|
||||
//{
|
||||
// SQL += " AND ac.drug_id='" + drug_id + "' ";
|
||||
//}
|
||||
if (type > 0)
|
||||
{
|
||||
if (type == 1)
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
SqlSugarHelper.Db.Insertable(new DrugBase()
|
||||
{
|
||||
DrugId = SelectedDrug.DrugId,
|
||||
DrugId = SelectedDrug.DrugId.ToString(),
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
|
||||
BaseQuantity = SelectedDrug.drugBase.BaseQuantity
|
||||
}).ExecuteCommand();
|
||||
|
@ -258,11 +258,11 @@ namespace DM_Weight.ViewModels
|
|||
SqlSugarHelper.Db.Updateable(SelectedDrug).UpdateColumns(d => new { d.DrugName, d.Manufactory, d.PyCode, d.PackUnit, d.MaxStock, d.DrugSpec }).ExecuteCommand();
|
||||
|
||||
|
||||
if (SelectedDrug.drugBase == null)
|
||||
if (SelectedDrug.drugBase == null || SelectedDrug.drugBase.BaseId == 0)
|
||||
{
|
||||
SqlSugarHelper.Db.Insertable(new DrugBase()
|
||||
{
|
||||
DrugId = SelectedDrug.DrugId,
|
||||
DrugId = SelectedDrug.DrugId.ToString(),
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
|
||||
BaseQuantity = SelectedDrug.drugBase.BaseQuantity
|
||||
}).ExecuteCommand();
|
||||
|
@ -276,8 +276,8 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
SqlSugarHelper.Db.Insertable(new DrugBase()
|
||||
{
|
||||
DrugId = SelectedDrug.DrugId,
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"]??"DM1",
|
||||
DrugId = SelectedDrug.DrugId.ToString(),
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
|
||||
BaseQuantity = SelectedDrug.drugBase.BaseQuantity
|
||||
}).ExecuteCommand();
|
||||
}
|
||||
|
@ -313,15 +313,69 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
get => new DelegateCommand(() =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(SelectedManuno.EffDate) && !string.IsNullOrEmpty(SelectedManuno.ManuNo))
|
||||
try
|
||||
{
|
||||
SelectedManuno.Id = Guid.NewGuid().ToString();
|
||||
SelectedManuno.DrugId = SelectedDrug.DrugId.ToString();
|
||||
SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
|
||||
SqlSugarHelper.Db.Insertable(SelectedManuno).ExecuteCommand();
|
||||
GetManuNos();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(SelectedManuno.EffDate) && !string.IsNullOrEmpty(SelectedManuno.ManuNo))
|
||||
{
|
||||
string dt = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
|
||||
int repeatCount = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.DrugId == SelectedDrug.DrugId.ToString() && dm.EffDate == dt && dm.ManuNo == SelectedManuno.ManuNo).Count();
|
||||
if (repeatCount > 0)
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "批次重复,请勿重复添加!",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedManuno.Id = Guid.NewGuid().ToString();
|
||||
SelectedManuno.DrugId = SelectedDrug.DrugId.ToString();
|
||||
SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
|
||||
int iResult = SqlSugarHelper.Db.Insertable(SelectedManuno).ExecuteCommand();
|
||||
AlertMsg alertMsg = new AlertMsg();
|
||||
if (iResult > 0)
|
||||
{
|
||||
alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "保存成功!",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "保存失败!",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
}
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
//GetManuNos();
|
||||
}
|
||||
else
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "请输入批次及效期!",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = $"添加失败{ex.Message}",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
}, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug);
|
||||
}
|
||||
|
||||
|
@ -329,9 +383,43 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
get => new DelegateCommand(() =>
|
||||
{
|
||||
SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
|
||||
SqlSugarHelper.Db.Updateable(SelectedManuno).UpdateColumns(m => new { m.ManuNo, m.EffDate }).ExecuteCommand();
|
||||
GetManuNos();
|
||||
try
|
||||
{
|
||||
|
||||
string dt = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
|
||||
int repeatCount = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.DrugId == SelectedDrug.DrugId.ToString() && dm.EffDate == dt && dm.ManuNo == SelectedManuno.ManuNo).Count();
|
||||
if (repeatCount > 0)
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "批次重复,请勿重复添加!",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
|
||||
SqlSugarHelper.Db.Updateable(SelectedManuno).UpdateColumns(m => new { m.ManuNo, m.EffDate }).ExecuteCommand();
|
||||
GetManuNos();
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "修改成功!",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "修改失败!",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
}, () => !string.IsNullOrEmpty(SelectedManuno.DrugId)).ObservesProperty(() => SelectedManuno);
|
||||
}
|
||||
|
||||
|
@ -369,10 +457,10 @@ namespace DM_Weight.ViewModels
|
|||
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (di) => di.DrugBarcode.Contains(SearchValue))
|
||||
//.Select(di => di)
|
||||
.ToPageList(PageNum, PageSize, ref totalCount);
|
||||
foreach(DrugInfo di in DrugInfos)
|
||||
foreach (DrugInfo di in DrugInfos)
|
||||
{
|
||||
|
||||
if(di.drugBase==null)
|
||||
if (di.drugBase == null)
|
||||
{
|
||||
di.drugBase = new DrugBase();
|
||||
}
|
||||
|
|
|
@ -306,33 +306,33 @@ namespace DM_Weight.ViewModels
|
|||
PremissionName = "归还药品",
|
||||
PremissionPath = "ReturnDrugWindow2",
|
||||
};
|
||||
//PremissionDm huanyao2 = new PremissionDm
|
||||
//{
|
||||
// Id = 32,
|
||||
// PremissionName = "归还空瓶",
|
||||
// PremissionPath = "ReturnEmptyWindow",
|
||||
//};
|
||||
PremissionDm huanyao2 = new PremissionDm
|
||||
{
|
||||
Id = 32,
|
||||
PremissionName = "空瓶销毁",
|
||||
PremissionPath = "ReturnEmptyDestoryWindow",
|
||||
PremissionName = "归还空瓶",
|
||||
PremissionPath = "ReturnEmptyWindow",
|
||||
};
|
||||
//PremissionDm huanyao2 = new PremissionDm
|
||||
//{
|
||||
// Id = 32,
|
||||
// PremissionName = "空瓶销毁",
|
||||
// PremissionPath = "ReturnEmptyDestoryWindow",
|
||||
//};
|
||||
PremissionDm huanyao3 = new PremissionDm
|
||||
{
|
||||
Id = 33,
|
||||
PremissionName = "归还记录",
|
||||
PremissionPath = "ReturnRecordWindow",
|
||||
};
|
||||
PremissionDm surgery = new PremissionDm
|
||||
{
|
||||
Id = 17,
|
||||
PremissionName = "手术核销",
|
||||
PremissionPath = "SurgeryTakeWindow"
|
||||
};
|
||||
//PremissionDm surgery = new PremissionDm
|
||||
//{
|
||||
// Id = 17,
|
||||
// PremissionName = "手术核销",
|
||||
// PremissionPath = "SurgeryTakeWindow"
|
||||
//};
|
||||
huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1 ? huanyao11 : huanyao1);
|
||||
huanyaoChild.Add(huanyao2);
|
||||
huanyaoChild.Add(surgery);
|
||||
//huanyaoChild.Add(surgery);
|
||||
huanyaoChild.Add(huanyao3);
|
||||
huanyao.Children = huanyaoChild;
|
||||
defaultAll.Add(huanyao);
|
||||
|
|
Loading…
Reference in New Issue