| | |
| | | |
| | | //} |
| | | |
| | | |
| | | |
| | | public override void AfterBarItemClick(AfterBarItemClickEventArgs e) |
| | | { |
| | | base.AfterBarItemClick(e); |
| | |
| | | { |
| | | //Entity entity = this.View.BillBusinessInfo.GetEntity("FEntity"); |
| | | //DynamicObjectCollection rows = this.Model.GetEntityDataObject(entity); |
| | | |
| | | this.Model.DeleteEntryData("FEntity"); |
| | | |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | | { |
| | | |
| | | //根据生产订单号和物料查询是否存在明细 |
| | | string sql = string.Format(@"/*dialect*/ SELECT T1.FBILLNO,T2.* FROM T_PRD_MO T1 |
| | | LEFT JOIN T_PRD_MOENTRY T2 ON T1.FID = T2.FID |
| | | JOIN T_BD_MATERIAL T3 ON T2.FMATERIALID = T3.FMATERIALID |
| | | WHERE T1.FBILLNO = '{0}' AND T3.FNUMBER = '{1}'", dt.Rows[i][1].ToString(), dt.Rows[i][5].ToString()); |
| | | DataTable _dt = new DataTable(); |
| | | _dt = DBServiceHelper.ExecuteDataSet(Context, sql).Tables[0]; |
| | | |
| | | |
| | | string FLOT = "";//FLOT 批次 |
| | | string FQTY = "";//FQTY 生产订单数量 |
| | | string FBILLNO = "";//FBILLNO 原单号 |
| | | |
| | | if (_dt.Rows.Count > 0) |
| | | { |
| | | FLOT = _dt.Rows[0]["FLOT"].ToString(); |
| | | FQTY = _dt.Rows[0]["FQTY"].ToString(); |
| | | FBILLNO = _dt.Rows[0]["FBILLNO"].ToString(); |
| | | } |
| | | |
| | | //DynamicObject row = new DynamicObject(entity.DynamicObjectType); |
| | | this.Model.CreateNewEntryRow("FEntity"); |
| | | this.Model.SetValue("FSEQ", i + 1, i); |
| | |
| | | this.Model.SetValue("FUnit", dt.Rows[i][8].ToString(), i); |
| | | this.Model.SetValue("FBatch", dt.Rows[i][9].ToString(), i); |
| | | this.Model.SetValue("FSalOrderCount", dt.Rows[i][10].ToString(), i); |
| | | this.Model.SetValue("FProOrderCount", dt.Rows[i][11].ToString(), i); |
| | | this.Model.SetValue("FCompleteSetCount", dt.Rows[i][12].ToString(), i); |
| | | this.Model.SetValue("FDeliveryDate", GetDateTime(Convert.ToInt32(dt.Rows[i][13].ToString())), i); |
| | | this.Model.SetValue("FDeliveryDate", ToDateTimeValue(dt.Rows[i][13].ToString()), i); |
| | | this.Model.SetValue("FOrderLevel", dt.Rows[i][14].ToString(), i); |
| | | this.Model.SetValue("FOrderQuantity", FQTY, i); |
| | | for (int j = 0; j <= 60; j++) |
| | | { |
| | | this.Model.SetValue("FT" + "" + j + "", dt.Rows[i][15 + j].ToString(), i); |
| | | } |
| | | |
| | | //entity.SeqDynamicProperty.SetValue(row, i + 1);//序号 |
| | | //row["FSalOrderNo"] = dt.Rows[i][0].ToString();//销售订单号 |
| | | //row["FSCOrderNo"] = dt.Rows[i][1].ToString();//生产订单号 |
| | | //row["FORGID"] = Convert.ToInt32(dt.Rows[i][2].ToString());//生产组织 |
| | | //row["FProductWorkShopId"] = Convert.ToInt32(dt.Rows[i][3].ToString());//生产车间 |
| | | //row["FResourcesId"] = Convert.ToInt32(dt.Rows[i][4].ToString());//生产资源 |
| | | //row["FMatrailId"] = dt.Rows[i][5].ToString(); //产品代码 |
| | | //row["FMatrailName"] = dt.Rows[i][6].ToString(); //产品名称 |
| | | //row["FModel"] = dt.Rows[i][7].ToString(); //规格型号 |
| | | //row["FUnit"] = dt.Rows[i][8].ToString(); //计量单位 |
| | | //row["FBatch"] = dt.Rows[i][9].ToString(); //批次号 |
| | | //row["FSalOrderCount"] = dt.Rows[i][10].ToString(); //销售订单数量 |
| | | //row["FProOrderCount"] = dt.Rows[i][11].ToString(); //生产订单数量 |
| | | //row["FCompleteSetCount"] = dt.Rows[i][12].ToString(); //总齐套数量 |
| | | //row["FDeliveryDate"] = GetDateTime(Convert.ToInt32(dt.Rows[i][13].ToString())); //交货日期 |
| | | //row["FOrderLevel"] = dt.Rows[i][14].ToString(); //订单等级 |
| | | //for (int j = 0; j <= 60; j++) |
| | | //{ |
| | | // row["FT" + "" + j + ""] = dt.Rows[i][15 + j].ToString(); |
| | | //} |
| | | //this.View.GetControl("FSalOrderNo").Text = "入库单号"; |
| | | //this.View.GetControl("FSCOrderNo").Text = "采购入库数量"; |
| | | // rows.Add(row); |
| | | //调用数量值更新 |
| | | this.View.InvokeFieldUpdateService("FT0", i); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | this.View.GetMainBarItem("TBWJSC").Enabled = false; //锁定按钮 |
| | | |
| | | |
| | | } |
| | |
| | | //单据体信息转换为列表集合 |
| | | DynamicObjectCollection entityDataObjoct = this.View.Model.GetEntityDataObject(entity); |
| | | |
| | | string _result = ""; |
| | | foreach (DynamicObject current in entityDataObjoct) |
| | | { |
| | | //根据生产订单号和物料查询是否存在明细 |
| | | sql = string.Format(@"/*dialect*/SELECT T1.FBILLNO,T2.* FROM T_PRD_MO T1 |
| | | LEFT JOIN T_PRD_MOENTRY T2 ON T1.FID = T2.FID |
| | | WHERE T1.FBILLNO = '{0}' AND T2.FMATERIALID = '{1}'", Convert.ToString(current["FSCOrderNo"]), Convert.ToString(current["FMatrailId_Id"])); |
| | | DataTable dt = new DataTable(); |
| | | dt = DBServiceHelper.ExecuteDataSet(Context, sql).Tables[0]; |
| | | if (dt.Rows.Count == 0) |
| | | _result += "序号:" + Convert.ToString(current["SEQ"]) + ",生产订单号:" + Convert.ToString(current["FSCOrderNo"]) + "对应的物料" + (current["FMatrailId"] as DynamicObject)["Number"] + "不存在"; |
| | | |
| | | } |
| | | if (_result != "") |
| | | { |
| | | this.View.ShowErrMessage(_result); |
| | | return; |
| | | } |
| | | |
| | | foreach (DynamicObject current in entityDataObjoct) |
| | | { |
| | | if (Convert.ToInt32(current["FNoScheduled"]) < 0) |
| | | _result += "序号:" + Convert.ToString(current["SEQ"]) + ",日计划总数量超出生产订单数量"; |
| | | |
| | | } |
| | | if (_result != "") |
| | | { |
| | | this.View.ShowErrMessage(_result); |
| | | return; |
| | | } |
| | | |
| | | foreach (DynamicObject current in entityDataObjoct) |
| | | { |
| | | if (string.IsNullOrEmpty(Convert.ToString(current["FSalOrderNo"])) || string.IsNullOrEmpty(Convert.ToString(current["FSCOrderNo"]))) |
| | |
| | | //根据生产订单号和物料查询是否存在明细 |
| | | sql = string.Format(@"/*dialect*/SELECT T1.FBILLNO,T2.* FROM T_PRD_MO T1 |
| | | LEFT JOIN T_PRD_MOENTRY T2 ON T1.FID = T2.FID |
| | | WHERE T1.FBILLNO = '{0}' ", Convert.ToString(current["FSCOrderNo"])); |
| | | WHERE T1.FBILLNO = '{0}' AND T2.FMATERIALID = '{1}'", Convert.ToString(current["FSCOrderNo"]), Convert.ToString(current["FMatrailId_Id"])); |
| | | DataTable dt = new DataTable(); |
| | | dt = DBServiceHelper.ExecuteDataSet(Context, sql).Tables[0]; |
| | | if (dt.Rows.Count == 0) |
| | | continue; |
| | | |
| | | string FID = "";//FID 源单主内码 |
| | | string FENTRYID = "";//FENTRYID 源单子内码 |
| | | string FLOT = "";//FLOT 批次 |
| | | string FQTY = "";//FQTY 生产订单数量 |
| | | string FBILLNO = "";//FBILLNO 原单号 |
| | | |
| | | if (dt.Rows.Count > 0) |
| | | { |
| | | FID = dt.Rows[0]["FID"].ToString(); |
| | |
| | | jsonModel.Add("FHOrderLev", current["FOrderLevel"].ToString());//订单等级 |
| | | jsonModel.Add("FSalOrderCount", current["FOrderLevel"].ToString());//销售订单数量 |
| | | jsonModel.Add("FHOrderCommitDate", current["FDeliveryDate"].ToString());//交货期HOrderCommitDate |
| | | //jsonModel.Add("FBatch", current["FBatch"].ToString());//批次 |
| | | //jsonModel.Add("FBatch", current["FBatch"].ToString());//批次 |
| | | jsonModel.Add("FBatch", FLOT);//批次 |
| | | jsonModel.Add("FHOrderNeedQty", FQTY);// 订单需求数量 |
| | | jsonModel.Add("FPrdBillNo", FBILLNO); ;//源单编号 |
| | | jsonModel.Add("FPRDMOMAINID", FID); ;//源单主内码 |
| | | jsonModel.Add("FPRDMOENTYID", FENTRYID); ;//源单子内码 |
| | | |
| | | jsonModel.Add("FOrderQuantity", current["FOrderQuantity"].ToString()); ;//生产订单数量 |
| | | jsonModel.Add("FDayPlanQuantity", current["FDayPlanQuantity"].ToString()); ;//日计划数量 |
| | | jsonModel.Add("FNoScheduled", current["FNoScheduled"].ToString()); ;//未排数量 |
| | | |
| | | |
| | | |
| | | |
| | | JObject jsonFHMaterID = new JObject(); |
| | | jsonFHMaterID.Add("FNumber", (current["FMatrailId"] as DynamicObject)["Number"].ToString()); |
| | | jsonModel.Add("FHMaterID", jsonFHMaterID);//FHMaterID 物料 |
| | | |
| | | JObject jsonFHPRDORGID = new JObject(); |
| | | jsonFHPRDORGID.Add("FNumber", (current["FORGID"] as DynamicObject)["Number"].ToString()); |
| | | jsonModel.Add("FHPRDORGID", jsonFHPRDORGID);//FHMaterID 生产组织 |
| | | if (Convert.ToString(current["FORGID_Id"]) != "0") |
| | | { |
| | | JObject jsonFHPRDORGID = new JObject(); |
| | | jsonFHPRDORGID.Add("FNumber", (current["FORGID"] as DynamicObject)["Number"].ToString()); |
| | | jsonModel.Add("FHPRDORGID", jsonFHPRDORGID);//FHMaterID 生产组织 |
| | | |
| | | //JObject jsonFProductWorkShopId = new JObject(); |
| | | //jsonFProductWorkShopId.Add("FNumber", (current["FProductWorkShopId"] as DynamicObject)["Number"].ToString()); |
| | | //jsonModel.Add("FHWorkShopID", jsonFProductWorkShopId);//FHMaterID 生产车间 |
| | | } |
| | | if (Convert.ToString(current["FResourcesId_Id"]) != "0") |
| | | { |
| | | JObject jsonFProductWorkShopId = new JObject(); |
| | | jsonFProductWorkShopId.Add("FNumber", (current["FResourcesId"] as DynamicObject)["Number"].ToString()); |
| | | jsonModel.Add("FHSourceID", jsonFProductWorkShopId);//FHSourceID 生产车间 |
| | | } |
| | | |
| | | //JObject jsonFResourcesId = new JObject(); |
| | | //jsonFHMaterID.Add("FNumber", (current["FResourcesId"] as DynamicObject)["Number"].ToString()); |
| | | //jsonModel.Add("FHSourceID", jsonFResourcesId);//FHMaterID 生产资源 |
| | | |
| | | if (Convert.ToString(current["FProductWorkShopId_Id"]) != "0") |
| | | { |
| | | JObject jsonFResourcesId = new JObject(); |
| | | jsonFResourcesId.Add("FNumber", (current["FProductWorkShopId"] as DynamicObject)["Number"].ToString()); |
| | | jsonModel.Add("FHWorkShopID", jsonFResourcesId);//FHWorkShopID 生产资源 |
| | | } |
| | | JArray Entry = new JArray(); |
| | | for (int i = 0; i <= 60; i++) |
| | | { |
| | |
| | | jsonFPOOrderEntry.Add("FHMasterDate", date.AddDays(i).ToShortDateString()); ;//主日期 |
| | | jsonFPOOrderEntry.Add("FHQty ", Convert.ToString(current["FT" + "" + i + ""])); ;//日计划数量 |
| | | jsonFPOOrderEntry.Add("FColumn", "FT" + "" + i + ""); ;//对应的列头 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceBillType ", "生产订单"); ;//源单类型 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceBillNo", FBILLNO); ;//源单编号 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceInterID", FID); ;//源单主内码 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceEntryID", FENTRYID); ;//源单子内码 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceBillType ", "生产订单"); ;//源单类型 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceBillNo", FBILLNO); ;//源单编号 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceInterID", FID); ;//源单主内码 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceEntryID", FENTRYID); ;//源单子内码 |
| | | |
| | | Entry.Add(jsonFPOOrderEntry); |
| | | } |
| | | |
| | | jsonModel.Add("FEntity", Entry); |
| | | jsonRoot.Add("Model", jsonModel); |
| | | |
| | | |
| | | CloudClient cloudClient = new CloudClient("http://localhost/K3Cloud/"); |
| | | var result = cloudClient.Save("Paez_Sc_WorkBillAutoSortBill", jsonRoot.ToString()); |
| | | JObject saveObj = JObject.Parse(result); |
| | | string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper(); |
| | | |
| | | if (saveIsSuc == "TRUE") |
| | | //日计划工单不为空时update |
| | | if (Convert.ToString(current["FDayPlanID"]) != "0") |
| | | { |
| | | this.View.ShowMessage("导入成功"); |
| | | jsonModel.Add("FID", Convert.ToString(current["FDayPlanID"])); ;//源单编号 |
| | | jsonRoot.Add("Model", jsonModel); |
| | | CloudClient cloudClient = new CloudClient("http://localhost/K3Cloud/"); |
| | | var result = cloudClient.Save("Paez_Sc_WorkBillAutoSortBill", jsonRoot.ToString()); |
| | | JObject saveObj = JObject.Parse(result); |
| | | string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper(); |
| | | |
| | | if (saveIsSuc == "TRUE") |
| | | { |
| | | string FDayPlanBillNo = saveObj["Result"]["Number"].ToString(); |
| | | string FDayPlanID = saveObj["Result"]["Id"].ToString(); |
| | | |
| | | this.Model.SetValue("FDayPlanBillNo", FDayPlanBillNo, Convert.ToInt32(current["SEQ"]) - 1);// |
| | | this.Model.SetValue("FDayPlanID", FDayPlanID, Convert.ToInt32(current["SEQ"]) - 1);// |
| | | |
| | | this.View.ShowMessage("导入成功"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | this.View.ShowErrMessage("导入失败"); |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | this.View.ShowErrMessage("导入失败"); |
| | | jsonRoot.Add("Model", jsonModel); |
| | | CloudClient cloudClient = new CloudClient("http://localhost/K3Cloud/"); |
| | | var result = cloudClient.Save("Paez_Sc_WorkBillAutoSortBill", jsonRoot.ToString()); |
| | | JObject saveObj = JObject.Parse(result); |
| | | string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper(); |
| | | |
| | | if (saveIsSuc == "TRUE") |
| | | { |
| | | string FDayPlanBillNo = saveObj["Result"]["Number"].ToString(); |
| | | string FDayPlanID = saveObj["Result"]["Id"].ToString(); |
| | | |
| | | this.Model.SetValue("FDayPlanBillNo", FDayPlanBillNo, Convert.ToInt32(current["SEQ"]) - 1);// |
| | | this.Model.SetValue("FDayPlanID", FDayPlanID, Convert.ToInt32(current["SEQ"]) - 1);// |
| | | |
| | | |
| | | this.View.ShowMessage("导入成功"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | this.View.ShowErrMessage("导入失败"); |
| | | |
| | | } |
| | | } |
| | | |
| | | this.View.UpdateView(); |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 数字转换时间格式 |
| | | /// </summary> |
| | | /// <param name="timeStr">数字,如:42095.7069444444/0.650694444444444</param> |
| | | /// <returns>日期/时间格式</returns> |
| | | private string ToDateTimeValue(string strNumber) |
| | | { |
| | | if (!string.IsNullOrWhiteSpace(strNumber)) |
| | | { |
| | | Decimal tempValue; |
| | | //先检查 是不是数字; |
| | | if (Decimal.TryParse(strNumber, out tempValue)) |
| | | { |
| | | //天数,取整 |
| | | int day = Convert.ToInt32(Math.Truncate(tempValue)); |
| | | //这里也不知道为什么. 如果是小于32,则减1,否则减2 |
| | | //日期从1900-01-01开始累加 |
| | | // day = day < 32 ? day - 1 : day - 2; |
| | | DateTime dt = new DateTime(1900, 1, 1).AddDays(day < 32 ? (day - 1) : (day - 2)); |
| | | |
| | | //小时:减掉天数,这个数字转换小时:(* 24) |
| | | Decimal hourTemp = (tempValue - day) * 24;//获取小时数 |
| | | //取整.小时数 |
| | | int hour = Convert.ToInt32(Math.Truncate(hourTemp)); |
| | | //分钟:减掉小时,( * 60) |
| | | //这里舍入,否则取值会有1分钟误差. |
| | | Decimal minuteTemp = Math.Round((hourTemp - hour) * 60, 2);//获取分钟数 |
| | | int minute = Convert.ToInt32(Math.Truncate(minuteTemp)); |
| | | //秒:减掉分钟,( * 60) |
| | | //这里舍入,否则取值会有1秒误差. |
| | | Decimal secondTemp = Math.Round((minuteTemp - minute) * 60, 2);//获取秒数 |
| | | int second = Convert.ToInt32(Math.Truncate(secondTemp)); |
| | | |
| | | //时间格式:00:00:00 |
| | | string resultTimes = string.Format("{0}:{1}:{2}", |
| | | (hour < 10 ? ("0" + hour) : hour.ToString()), |
| | | (minute < 10 ? ("0" + minute) : minute.ToString()), |
| | | (second < 10 ? ("0" + second) : second.ToString())); |
| | | |
| | | if (day > 0) |
| | | return string.Format("{0} {1}", dt.ToString("yyyy-MM-dd"), resultTimes); |
| | | else |
| | | return resultTimes; |
| | | } |
| | | } |
| | | return string.Empty; |
| | | } |
| | | |
| | | } |
| | | |