/// <summary> /// Check a social matrix is asymmetric? /// </summary> /// <param name="links"></param> /// <returns></returns> public static bool IsAsymmetric(List <Link> links) { Console.WriteLine("links,{0}", links.Count); MyTable table = Tools.GetLinkTable(links); int counter = 0; foreach (int f in table.Keys) { Hashtable subTable = (Hashtable)table[f]; foreach (int t in subTable.Keys) { if (!table.ContainsKey(t, f)) { // Console.WriteLine("{0},{1}", f, t); counter++; } } } Console.WriteLine("counter,{0}", counter); return(counter == 0 ? true : false); }
public void MergeTest2() { var instance1 = new MyTable(); var instance2 = new MyTable(); instance1.Entity.SetIdentity(1); instance2.Entity.SetIdentity(1); instance1.Entity.Reset(); instance2.Entity.Reset(); instance1.MyString = "test"; instance2.MyNumber = 5; Assert.IsTrue(instance1.Entity.LastModified.HasValue); Assert.AreEqual(instance1.Entity.Changes.Count(), 1); Assert.IsTrue(instance2.Entity.LastModified.HasValue); Assert.AreEqual(instance2.Entity.Changes.Count(), 1); instance2.Entity.Merge(instance1); Assert.AreEqual(instance1.Entity.Changes.Count(), 1); Assert.AreEqual(instance2.Entity.Changes.Count(), 2); Assert.AreEqual(instance2.Entity.State, instance1.Entity.State); instance1.Entity.Reset(); instance2.Entity.Reset(); instance2.MyNumber = 5; instance2.Entity.Merge(instance1); Assert.AreEqual(instance2.Entity.Changes.Count(), 1); Assert.AreEqual(instance2.Entity.State, EntityState.Modified); Assert.AreNotEqual(instance2.Entity.State, instance1.Entity.State); instance1.Entity.Delete(); instance2.Entity.Merge(instance1); Assert.AreEqual(instance2.Entity.State, EntityState.Deleted); }
public async Task <IActionResult> SaveRecord() { // C - Create var r = new MyTable() { Id = 0, EmpName = "Harish", Salary = 2000, DOB = Convert.ToDateTime("2010-01-01") }; MyTable myTable = new MyTable(); myTable.Id = 0; myTable.EmpName = "Harish"; myTable.Salary = 2000; myTable.DOB = Convert.ToDateTime("2010-01-01"); _context.MyTables.Add(myTable); // EF _context.MyTables.Add(new MyTable { Id = 0, EmpName = "Ramesh1", Salary = 1000 }); // EF _context.MyTables.Add(GetMyTableObj()); /********************************/////// List <MyTable> myTables = new List <MyTable>(); myTables.Add(r); myTables.Add(myTable); _context.MyTables.AddRange(myTables); // EF await _context.SaveChangesAsync(); // EF return(Ok()); // return await _context.MyTables.ToListAsync(); }
//字典类别删除 protected void btnDel_Click(object sender, EventArgs e) { MyTable mtTable = new MyTable(strTable, "CODE"); mtTable.ColRow["CODE"] = PubFunc.FormDataGet(FormMx, "CODE"); if (PubFunc.StrIsEmpty(mtTable.ColRow["CODE"].ToString())) { Alert.Show("请选择要删除的数据!"); return; } else if (DbHelperOra.Exists("select 1 from " + strTable + " where SJCODE='" + mtTable.ColRow["CODE"].ToString() + "'")) { Alert.Show("数据【" + mtTable.ColRow["CODE"].ToString() + "】有下级,不能删除!"); return; } mtTable.DeleteExec(""); InitDdl(); InitTree(); InitFrom(""); tbxCode.Enabled = true; TreeDic.SelectedNodeID = null;//解决删除后点击增加会报错的问题 Alert.Show("数据【" + mtTable.ColRow["CODE"] + "】删除成功!"); }
protected void btnSave_Click(object sender, EventArgs e) { if (!chkMONDAY.Checked && !chkTUESDAY.Checked && !chkWEDNESDAY.Checked && !chkTHURSDAY.Checked && !chkFRIDAY.Checked && !chkSATURDAY.Checked && !chkSUNDAY.Checked) { Alert.Show("请选择业务操作的周期!", "操作提示", MessageBoxIcon.Warning); return; } MyTable mtType = new MyTable("DAT_WORK"); mtType.ColRow = PubFunc.FormDataHT(FormMange); if (!DbHelperOra.Exists(string.Format("SELECT 1 FROM DAT_WORK WHERE DEPTID = '{0}' AND TYPE = '{1}'", ddlDEPTID.SelectedValue, ddlTYPE.SelectedValue))) { mtType.InsertExec(); } else { mtType.UpdateExec(""); } Alert.Show("数据保存成功!"); dataSearch(); PubFunc.FormDataClear(FormMange); }
public void IdentityComparisonTest() { var instance1 = new MyTable(); var instance2 = new MyTable(); instance1.Entity.SetIdentity(1); instance2.Entity.SetIdentity(1); instance1.Entity.Reset(); instance2.Entity.Reset(); Assert.AreEqual(instance1.Entity.State, EntityState.Current); Assert.AreEqual(instance1.Entity.State, EntityState.Current); Assert.AreEqual(instance1.Entity.Changes.Count(), 0); Assert.IsTrue(instance1.Entity.SameAs(instance2)); Assert.IsTrue(instance1.Entity.SameAs(instance2)); instance2.Entity.SetIdentity(2); Assert.AreEqual(instance1.Entity.State, EntityState.Current); Assert.AreEqual(instance1.Entity.Changes.Count(), 0); Assert.IsFalse(instance1.Entity.SameAs(instance2)); Assert.IsFalse(instance1.Entity.SameAs(instance2)); }
public void AddFailTest() { var my1 = new MyTable() { MyIdentity = 1, MyNumber = 1, MyString = "One" }; var index = CreateIDbIndex <int, MyTable>((i) => i.MyIdentity); index.AddOrFail(my1); try { index.AddOrFail(my1); Assert.True(false); } catch (ArgumentException) { Assert.True(true); } }
/// <summary> /// Fills the control MyGridView2 with the content of the table tableToPut. /// The form is displayed modally. /// Throws an exception if any row of the table "tableToPut" contains larger number of elements than the /// argument "myHeader". /// The string "myTitle" is a title which is displayed at the form. /// </summary> /// <param name="tableToPut">The table which will be placed in the control MyGridView2</param> /// <param name="myHeader">The header placed in the first row of the control MyGridView2</param> /// <param name="omitHeader">determines if the header's display is omitted</param> public DialogResult DisplayGrid(MyTable tableToPut, List <string> myHeader, bool omitHeader = false, string myTitle = "") { int MaxCount = tableToPut.Content.Select(Element => Element.Count()).ToList().Max(); if (MaxCount > myHeader.Count()) { throw new ArgumentException("Wrong arguments passed to the function DisplayGrid"); } for (int Iterator = 1; Iterator <= myHeader.Count(); Iterator++) { MyGridView2.Columns.Add(myHeader[Iterator - 1], myHeader[Iterator - 1]); } int GridRow = 1; int TableRow = 1; if (omitHeader) { TableRow += 1; } MyGridView2.RowCount = tableToPut.RowCount(); this.Text = myTitle; while (TableRow <= (tableToPut.Count())) { for (int ColumnIterator = 1; ColumnIterator <= tableToPut[TableRow - 1].Count(); ColumnIterator++) { MyGridView2[ColumnIterator - 1, GridRow - 1].Value = tableToPut.Content[TableRow - 1][ColumnIterator - 1]; } GridRow += 1; TableRow += 1; } // CheckState(); DialogResult MyOutcome = ShowDialog(); return(MyOutcome); }
public static void Evaluation(List <Link> recommendations, List <Link> test) { MyTable table = new MyTable(); foreach (Link e in test) { if (!table.ContainsKey(e.From, e.To)) { table.Add(e.From, e.To, null); } } int hit = 0; foreach (Link e in recommendations) { if (table.ContainsKey(e.From, e.To)) { hit++; } } Console.WriteLine("{0}, {1}", hit * 1.0 / recommendations.Count, hit * 1.0 / test.Count); }
public void MergeTest() { var instance1 = new MyTable(); var instance2 = new MyTable(); instance1.MyString = "test"; instance2.Entity.Merge(instance1); Assert.IsTrue(instance1.Entity.LastModified.HasValue); Assert.IsTrue(instance2.Entity.LastModified.HasValue); Assert.AreEqual(instance1.Entity.LastModified.Value, instance2.Entity.LastModified.Value); instance1.Entity.SetIdentity(1); instance2.Entity.SetIdentity(1); instance1.Entity.Reset(); instance2.Entity.Reset(); instance2.Entity.Merge(instance1); Assert.AreEqual(instance2.MyIdentity, 1); Assert.AreEqual(instance2.MyString, "test"); Assert.IsTrue(instance1.Entity.SameAs(instance2)); Assert.IsFalse(instance1.Entity.LastModified.HasValue); Assert.IsFalse(instance2.Entity.LastModified.HasValue); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <MyTable> patch) { // Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } MyTable myTable = db.MyTables.Find(key); if (myTable == null) { return(NotFound()); } patch.Patch(myTable); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MyTableExists(key)) { return(NotFound()); } else { throw; } } return(Updated(myTable)); }
public static bool saveDoc(MyTable MyTb, string tableName, string billNo) { List <CommandInfo> cmdList = new List <CommandInfo>(); try { MyTb.ColRow.Add("SUBSUM", DbHelperOra.GetSingle(string.Format("SELECT SUM(HSJE) FROM {0} WHERE SEQNO = '{1}'", tableName.Substring(0, tableName.Length - 3) + "COM", billNo))); MyTb.ColRow.Add("SUBNUM", DbHelperOra.GetSingle(string.Format("SELECT COUNT(1) FROM {0} WHERE SEQNO = '{1}'", tableName.Substring(0, tableName.Length - 3) + "COM", billNo))); } catch { } cmdList.Add(new CommandInfo(string.Format("DELETE {0} WHERE SEQNO='{1}'", tableName, billNo), null));//删除单据台头 cmdList.AddRange(MyTb.InsertCommand()); if (DbHelperOra.ExecuteSqlTran(cmdList)) { return(true); } else { return(false); } }
protected void btnGoodsConfig_Click(object sender, EventArgs e) { int[] deptArray = GridDepartment.SelectedRowIndexArray; string strGoods = ""; string strGoodsTR = ""; if (deptArray.Length > 0) { int[] selectArray = GridGoodsConfig.SelectedRowIndexArray; //if (selectArray.Length > 0) //{ List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable myGoodsCFG = new MyTable("DOC_GOODSCFG"); for (int j = 0; j < selectArray.Length; j++) { cmdList.Add(new CommandInfo(string.Format("delete doc_goodscfg where gdseq='{0}'", GridGoodsConfig.Rows[selectArray[j]].Values[1].ToString()), null)); } DataTable dtcfggrid = DbHelperOra.QueryForTable(string.Format(@"SELECT DEPTID FROM DOC_GOODSCFG WHERE GDSEQ='{0}'", GridGoodsConfig.Rows[GridGoodsConfig.SelectedRowIndex].Values[1].ToString())); bool isexist = false; if (dtcfggrid.Rows.Count > 0) { DataTable canceldt = PubFunc.GridDataGet(GridDepartment, GridDepartment.SelectedRowIndexArray); canceldt.Columns.Remove("DEPTNAME"); canceldt.Columns.Remove("DEPTTYPE"); foreach (DataRow dr in dtcfggrid.Rows) { foreach (DataRow drs in canceldt.Rows) { if (dr["DEPTID"].ToString().Equals(drs["CODE"].ToString())) { isexist = true; break; } else { isexist = false; } } if (!isexist) { DataTable dtcfgdb = DbHelperOra.QueryForTable(string.Format(@"SELECT DGC.DEPTID,SD.NAME DEPTNAME FROM DOC_GOODSCFG DGC ,SYS_DEPT SD WHERE DGC.DEPTID=SD.CODE AND (SELECT f_getkcgdseq(SD.CODE,DGC.GDSEQ,'') FROM DUAL)>0 AND SD.CODE='{0}' AND DGC.GDSEQ='{1}'", dr["DEPTID"].ToString(), GridGoodsConfig.Rows[GridGoodsConfig.SelectedRowIndex].Values[1].ToString())); if (dtcfgdb.Rows.Count > 0) { foreach (DataRow dre in dtcfgdb.Rows) { Alert.Show("科室【" + dre["DEPTNAME"].ToString() + "】中此商品尚有库存,不能取消配置"); return; } } } } for (int i = 0; i < deptArray.Length; i++) { string strDEPT = GridDepartment.Rows[deptArray[i]].Values[0].ToString(); string strTYPE = GridDepartment.Rows[deptArray[i]].Values[2].ToString(); string strInsertSql = ""; for (int j = 0; j < selectArray.Length; j++) { strGoods = "'" + GridGoodsConfig.Rows[selectArray[j]].Values[1].ToString() + "',"; strGoodsTR = strGoods.TrimEnd(','); if (strTYPE.Equals("3")) { strInsertSql = string.Format(@"INSERT INTO doc_goodscfg (GDSEQ, DEPTID, HJCODE1) VALUES({0}, '{1}', '{2}')", strGoodsTR, strDEPT, strDEPT); } else { strInsertSql = string.Format(@"INSERT INTO doc_goodscfg (GDSEQ, DEPTID, HJCODE1) VALUES({0}, '{1}', '{2}')", strGoodsTR, strDEPT, ""); } cmdList.Add(new CommandInfo(strInsertSql, null)); } #region //string strSqls = String.Format("SELECT 1 FROM DOC_GOODSCFG A,SYS_DEPT B WHERE A.DEPTID = B.CODE AND B.TYPE = '1' AND A.GDSEQ = '{0}' AND DEPTID = '{1}'", GridGoodsConfig.Rows[selectArray[j]].Values[1].ToString(), GridDepartment.Rows[selectArray[i]].Values[0].ToString()); // if ( !DbHelperOra.Exists(strSqls)) // { // //Alert.Show(string.Format("商品【{0}】已配置到库房【{1}】!", GridGoods.Rows[selectArray[i]].Values[2].ToString(), OBJ), "消息提示", MessageBoxIcon.Warning); // //return; // myGoodsCFG.ColRow.Clear(); // myGoodsCFG.ColRow.Add("GDSEQ", GridGoodsConfig.Rows[selectArray[j]].Values[1]); // myGoodsCFG.ColRow.Add("DEPTID", GridDepartment.Rows[selectArray[j]].Values[0]); // myGoodsCFG.ColRow.Add("ISCFG", "Y"); // myGoodsCFG.ColRow.Add("NUM1", "0"); // myGoodsCFG.ColRow.Add("NUM3", "0"); // myGoodsCFG.ColRow.Add("DSNUM", "0"); // if (DbHelperOra.Exists("SELECT 1 FROM SYS_DEPT WHERE CODE = '" + GridDepartment.Rows[selectArray[i]].Values[0].ToString() + "' AND TYPE IN('1','2')")) // { // trbHJCODE1.Enabled = true; // } // else // { // myGoodsCFG.ColRow.Add("HJCODE1", GridDepartment.Rows[selectArray[i]].Values[0].ToString()); // trbHJCODE1.Enabled = false; // } // cmdList.Add(myGoodsCFG.Insert()); // OperLog("商品配置", "修改科室【" + GridDepartment.Rows[selectArray[i]].Values[0] + "】商品【" + GridGoodsConfig.Rows[selectArray[j]].Values[1] + "】"); // } //if (GridGoods.Rows[selectArray[i]].Values[8].ToString() != "Y") //{ // //Alert.Show(string.Format("商品【{0}】状态信息错误!", GridGoods.Rows[selectArray[i]].Values[2].ToString()), "消息提示", MessageBoxIcon.Warning); // return; //} #endregion } } if (DbHelperOra.ExecuteSqlTran(cmdList)) { Alert.Show("保存成功"); } //} //else //{ // Alert.Show("请选择要进行配置的商品信息!"); // GridGoods.Focus(); //} } else { Alert.Show("请选择要进行配置的部门!"); ddlDept.Focus(); } }
private void save(string flag = "N") { #region 数据有效性验证 if (docFLAG.SelectedValue != "N") { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().ToList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } if (PubFunc.FormDataCheck(FormDoc).Length > 0) { return; } decimal subsum = 0; List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行、批号填写是否符合要求 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString()) && !string.IsNullOrWhiteSpace(newDict[i]["GDNAME"].ToString())) { //if (newDict[i]["ISLOT"].ToString() == "1" || newDict[i]["ISLOT"].ToString() == "2") //{ // if (string.IsNullOrWhiteSpace(newDict[i]["PH"].ToString()) || newDict[i]["PH"].ToString() == "\\") // { // //GridGoods.SelectedCell = new int[] { i, 8 }; // string[] selectedCell = GridGoods.SelectedCell; // PageContext.RegisterStartupScript(String.Format("F('{0}').selectCell('{1}','{2}');", GridGoods.ClientID, selectedCell[0], "KCSL")); // Alert.Show("商品【" + newDict[i]["GDNAME"].ToString() + "】批号不能为空!!!", "消息提示", MessageBoxIcon.Warning); // return; // } //} //if (newDict[i].ContainsKey("STR1")&&goodsData.Count > 0 && goodsData.Where(x => x["STR1"].ToString() == newDict[i]["STR1"].ToString()).Count() > 0) //{ // Alert.Show("条码[" + newDict[i]["STR1"] + "]扫描重复!", "消息提示", MessageBoxIcon.Warning); // return; if (!string.IsNullOrWhiteSpace(newDict[i]["STR1"].ToString())) { for (int k = 1 + i; k < newDict.Count; k++) { if ((newDict[i]["STR1"].ToString()) == (newDict[k]["STR1"].ToString())) { Alert.Show("商品『" + newDict[k]["GDNAME"].ToString() + "』条码『" + newDict[k]["STR1"].ToString() + "』重复,请维护!", "消息提示", MessageBoxIcon.Warning); return; } } } if (newDict[i]["BZSL"].ToString() == "0" || string.IsNullOrWhiteSpace(newDict[i]["BZSL"].ToString())) { Alert.Show("商品【" + newDict[i]["GDNAME"].ToString() + "】使用数填写不正确!", "消息提示", MessageBoxIcon.Warning); return; } if (decimal.Parse(newDict[i]["KCSL"].ToString()) < decimal.Parse(newDict[i]["BZSL"].ToString())) { Alert.Show("商品【" + newDict[i]["GDNAME"].ToString() + "】使用数大于库存数,请重新输入!", "消息提示", MessageBoxIcon.Warning); return; } //当商品中含有贵重商品信息,即需要赋唯一码时 if (newDict[i]["ISGZ"].ToString() == "Y" && newDict[i]["ONECODE"].ToString() == "") { Alert.Show("商品【" + newDict[i]["GDNAME"].ToString() + "】为贵重商品,请先进行扫描赋码!", "消息提示", MessageBoxIcon.Warning); return; } goodsData.Add(newDict[i]); subsum += Convert.ToDecimal(newDict[i]["HSJJ"].ToString()) * Convert.ToDecimal(newDict[i]["BZHL"].ToString()); } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } //验证单据信息 if (DbHelperOra.Exists("SELECT 1 FROM DAT_XS_DOC where seqno = '" + docBILLNO.Text + "'") && docBILLNO.Enabled) { Alert.Show("您输入的单号已存在,请检查!"); return; } #endregion if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docSEQNO.Text = BillSeqGet(); docBILLNO.Text = docSEQNO.Text; docBILLNO.Enabled = false; } else { string flg = (string)DbHelperOra.GetSingle(string.Format("SELECT NVL(FLAG,'N') FROM DAT_XS_DOC WHERE SEQNO='{0}'", docBILLNO.Text)); if (!string.IsNullOrWhiteSpace(flg) && (",N,R").IndexOf(flg) < 0) { Alert.Show("您输入的单据号存在重复信息,请重新输入或置空!", "消息提示", MessageBoxIcon.Warning); return; } else { docSEQNO.Text = docBILLNO.Text; docBILLNO.Enabled = false; } } MyTable mtType = new MyTable("DAT_XS_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow.Add("BILLTYPE", BillType); mtType.ColRow.Add("SUBNUM", goodsData.Count); mtType.ColRow.Add("XSTYPE", "1"); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_XS_COM"); //先删除单据信息在插入 cmdList.Add(new CommandInfo("delete DAT_XS_DOC where seqno='" + docBILLNO.Text + "'", null)); //删除单据台头 cmdList.Add(new CommandInfo("delete DAT_XS_COM where seqno='" + docBILLNO.Text + "'", null)); //删除单据明细 decimal subNum = 0; for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); if (PubFunc.StrIsEmpty(mtTypeMx.ColRow["BZSL"].ToString()) || mtTypeMx.ColRow["BZSL"].ToString() == "0") { Alert.Show("商品【" + mtTypeMx.ColRow["GDSEQ"] + " | " + mtTypeMx.ColRow["GDNAME"] + "】【使用数】为0或空,无法进行【使用信息管理】操作。"); return; } mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Add("PHID", mtTypeMx.ColRow["PH"]); mtTypeMx.ColRow["DHSL"] = decimal.Parse(mtTypeMx.ColRow["BZHL"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()); mtTypeMx.ColRow["HSJE"] = decimal.Parse(mtTypeMx.ColRow["HSJJ"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZHL"].ToString()); //mtTypeMx.ColRow["XSSL"] = goodsData[i]["DHSL"].ToString(); mtTypeMx.ColRow["XSSL"] = mtTypeMx.ColRow["DHSL"]; mtTypeMx.ColRow.Add("BHSJJ", 0); mtTypeMx.ColRow.Add("BHSJE", 0); mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); subNum = subNum + decimal.Parse(mtTypeMx.ColRow["HSJE"].ToString()); cmdList.Add(mtTypeMx.Insert()); } mtType.ColRow.Add("SUBSUM", subNum); cmdList.AddRange(mtType.InsertCommand()); if (DbHelperOra.ExecuteSqlTran(cmdList)) { if (flag == "N") { Alert.Show("商品使用信息保存成功!"); } OperLog("使用管理", "修改单据【" + docBILLNO.Text + "】"); billOpen(docBILLNO.Text); } SaveSuccess = true; }
protected void btnOk() { if (Doc.DbGetSysPara("LOCKSTOCK") == "Y") { Alert.Show("系统库存已被锁定,请等待物资管理科结存处理完毕再做审核处理!", "消息提醒", MessageBoxIcon.Warning); return; } #region 数据有效性验证 decimal subsum = 0;//总金额 if (docFLAG.SelectedValue != "S") { Alert.Show("非『已审批』单据不能申领确定!", "提示信息", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } //验证科室是否盘点 if (DbHelperOra.Exists("SELECT 1 FROM DAT_PD_LOCK WHERE DEPTID IN('" + docDEPTOUT.SelectedValue + "','" + docDEPTID.SelectedValue + "') AND FLAG='N'")) { Alert.Show("出库或申领科室正在盘点,请检查!"); return; } List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString()) && !string.IsNullOrWhiteSpace(newDict[i]["GDNAME"].ToString())) { goodsData.Add(newDict[i]); subsum = subsum + decimal.Parse(newDict[i]["HSJE"].ToString()); } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } //验证单据信息 if (DbHelperOra.Exists("SELECT 1 FROM DAT_CK_DOC WHERE SEQNO = '" + docBILLNO.Text + "'") && docBILLNO.Enabled) { Alert.Show("您输入的单号已存在,请检查!"); return; } #endregion if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docSEQNO.Text = BillSeqGet(); docBILLNO.Text = docSEQNO.Text; docBILLNO.Enabled = false; } else { string flg = (string)DbHelperOra.GetSingle(string.Format("SELECT NVL(FLAG,'N') FROM DAT_CK_DOC WHERE SEQNO='{0}'", docBILLNO.Text)); if (!PubFunc.StrIsEmpty(flg) && (",N,R,S").IndexOf(flg) < 0) { Alert.Show("您输入的单据号存在重复信息,请重新输入或置空!", "消息提示", MessageBoxIcon.Warning); return; } else { docSEQNO.Text = docBILLNO.Text; docBILLNO.Enabled = false; } } MyTable mtType = new MyTable("DAT_CK_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow.Add("BILLTYPE", BillType); mtType.ColRow.Add("SUBNUM", goodsData.Count); mtType.ColRow.Add("SUBSUM", subsum); mtType.ColRow.Add("XSTYPE", "1"); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_CK_COM"); //MyTable mtTypeExt = new MyTable("DAT_CK_EXT"); //先删除单据信息在插入 cmdList.Add(mtType.DeleteCommand("")); //删除单据台头 cmdList.Add(new CommandInfo("delete dat_ck_com where seqno='" + docBILLNO.Text + "'", null)); //删除单据明细 cmdList.AddRange(mtType.InsertCommand()); for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Add("PHID", mtTypeMx.ColRow["PH"]); mtTypeMx.ColRow["XSSL"] = decimal.Parse(mtTypeMx.ColRow["BZHL"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()); mtTypeMx.ColRow["HSJE"] = decimal.Parse(mtTypeMx.ColRow["HSJJ"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()); if (decimal.Parse(mtTypeMx.ColRow["XSSL"].ToString()) < 0 || (decimal.Parse(mtTypeMx.ColRow["XSSL"].ToString()) > decimal.Parse(mtTypeMx.ColRow["DHSL"].ToString()) && (mtTypeMx.ColRow["NUM1NAME"].ToString() == "非赠品"))) { Alert.Show("单据号中存在拣货数量小于0或拣货数量大于申领数量!", "消息提示", MessageBoxIcon.Warning); return; } mtTypeMx.ColRow.Add("BHSJJ", 0); mtTypeMx.ColRow.Add("BHSJE", 0); mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); cmdList.Add(mtTypeMx.Insert()); } OracleParameter[] parameters = { new OracleParameter("VTASKID", OracleDbType.Varchar2, 20), new OracleParameter("VPARA", OracleDbType.Varchar2, 800) }; parameters[0].Value = BillType; parameters[1].Value = "'" + docBILLNO.Text + "','" + BillType + "','" + UserAction.UserID + "','AUDIT'"; cmdList.Add(new CommandInfo("P_EXECTASK", parameters, CommandType.StoredProcedure)); bool flag = false; try { flag = DbHelperOra.ExecuteSqlTran(cmdList); } catch (Exception ex) { Alert.Show(errorParse(ex.Message), "消息提示", MessageBoxIcon.Warning); return; } if (flag) { billLockDoc(true); //增加待办事宜 DbHelperOra.ExecuteSql("UPDATE DAT_DO_LIST SET FLAG = 'Y' WHERE PARA='" + docBILLNO.Text.Trim() + "'"); if (DbHelperOra.Exists("select 1 from dat_ck_com where seqno = '" + docBILLNO.Text.Trim() + "' and gdseq in (select gdseq from doc_goods where catid0 = 1 )") == true) { Alert.Show("商品出库确认完成!需要打印试剂条码!", "消息提示", MessageBoxIcon.Information); } else { Alert.Show("商品出库确认完成!", "消息提示", MessageBoxIcon.Information); OperLog("科室申领", "出库确认单据【" + docBILLNO.Text + "】"); } billOpen(docBILLNO.Text); } else { Alert.Show("商品出库确认出错!!!", "错误提示", MessageBoxIcon.Error); } }
private void save(string flag = "N") { #region 数据有效性验证 if ((",M,R").IndexOf(ddlFLAG.SelectedValue) < 0) { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } if (PubFunc.FormDataCheck(FormDoc).Length > 0) { return; } if (GridGoods.Rows.Count() == 0) { Alert.Show("请先进行数据维护,再进行保存操作!", "消息提示", MessageBoxIcon.Warning); return; } //验证单据信息 if (DbHelperOra.Exists("SELECT 1 FROM DAT_TZSUP_DOC where seqno = '" + tbxBILLNO.Text + "'") && tbxBILLNO.Enabled) { Alert.Show("您输入的单号已存在,请检查!"); return; } #endregion if (PubFunc.StrIsEmpty(tbxBILLNO.Text)) { tbxSEQNO.Text = BillSeqGet(); tbxBILLNO.Text = tbxSEQNO.Text; tbxBILLNO.Enabled = false; } else { string flg = (string)DbHelperOra.GetSingle(string.Format("SELECT NVL(FLAG,'M') FROM DAT_TZSUP_DOC WHERE SEQNO='{0}'", tbxBILLNO.Text)); if (!string.IsNullOrWhiteSpace(flg) && (",M,R").IndexOf(flg) < 0) { Alert.Show("您输入的单据号存在重复信息,请重新输入或置空!", "消息提示", MessageBoxIcon.Warning); return; } else { tbxSEQNO.Text = tbxBILLNO.Text; tbxBILLNO.Enabled = false; } } MyTable mtType = new MyTable("DAT_TZSUP_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = tbxBILLNO.Text; mtType.ColRow.Add("SUBNUM", GridGoods.Rows.Count); mtType.ColRow.Add("XGTYPE", ddlType.SelectedValue); mtType.ColRow.Add("BILLTYPE", "TZL"); mtType.ColRow["FLAG"] = "M"; List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_TZSUP_COM"); //先删除单据信息在插入 cmdList.Add(new CommandInfo("delete DAT_TZSUP_DOC where seqno='" + tbxBILLNO.Text + "'", null)); //删除单据台头 cmdList.Add(new CommandInfo("delete DAT_TZSUP_COM where seqno='" + tbxBILLNO.Text + "'", null)); //删除单据明细 cmdList.AddRange(mtType.InsertCommand()); int index = 0; foreach (GridRow row in GridGoods.Rows) { index++; mtTypeMx.ColRow = PubFunc.GridDataGet(row); mtTypeMx.ColRow["SEQNO"] = tbxBILLNO.Text; mtTypeMx.ColRow["ROWNO"] = index; cmdList.Add(mtTypeMx.Insert()); } if (DbHelperOra.ExecuteSqlTran(cmdList)) { Alert.Show("供应商信息保存成功!"); OperLog("供应商管理", "修改单据【" + tbxBILLNO.Text + "】"); billOpen(tbxBILLNO.Text); } SaveSuccess = true; }
protected void btnRejectSubmit_Click(object sender, EventArgs e) { if (ddlType.SelectedValue != "D") { if (PubFunc.FormDataCheck(FormProducer).Length > 0) { return; } } if (tbxSUPID.Text.Trim().Length > 1) { if (DbHelperOra.Exists("select 1 from DOC_SUPPLIERTEMP where SUPID='" + tbxSUPID.Text + "'")) { DbHelperOra.ExecuteSql("DELETE FROM DOC_SUPPLIERTEMP WHERE SUPID='" + tbxSUPID.Text + "'"); } } if (hfdIsNew.Text == "N" && tbxSUPID.Text.Trim().Length < 1) { DataTable dt = DbHelperOra.QueryForTable("SELECT F_GET_SUPCODE FROM DUAL"); if (dt.Rows.Count > 0) { tbxSUPID.Text = dt.Rows[0][0].ToString(); } } else if (hfdIsNew.Text == "M" && tbxSUPID.Text.Trim().Length > 0) { if (DbHelperOra.Exists("select 1 from DOC_SUPPLIERTEMP where SUPID='" + tbxSUPID.Text + "'")) { DbHelperOra.ExecuteSql("DELETE FROM DOC_SUPPLIERTEMP WHERE SUPID='" + tbxSUPID.Text + "'"); } } else if (hfdIsNew.Text == "D") { for (int i = 0; i < GridSupplier.SelectedRowIndexArray.Length; i++) { if (DbHelperOra.Exists("select 1 from DOC_SUPPLIERTEMP where SUPID='" + GridSupplier.Rows[GridSupplier.SelectedRowIndexArray[i]].DataKeys[0] + "'")) { DbHelperOra.ExecuteSql("DELETE FROM DOC_SUPPLIERTEMP WHERE SUPID='" + GridSupplier.Rows[GridSupplier.SelectedRowIndexArray[i]].DataKeys[0] + "'"); } if (DbHelperOra.Exists("select 1 from DOC_SUPPLIER where SUPID='" + GridSupplier.Rows[GridSupplier.SelectedRowIndexArray[i]].DataKeys[0] + "'")) { DbHelperOra.ExecuteSql("INSERT INTO DOC_SUPPLIERTEMP SELECT * FROM DOC_SUPPLIER where SUPID='" + GridSupplier.Rows[GridSupplier.SelectedRowIndexArray[i]].DataKeys[0] + "' "); } hfdTEMP.Text += GridSupplier.Rows[GridSupplier.SelectedRowIndexArray[i]].DataKeys[0] + ","; } GridInIt(); WindowGoods.Hidden = true; return; } MyTable mtType = new MyTable("DOC_SUPPLIERTEMP"); if (tbxSUPNAME.Text.Trim().Length < 1) { Alert.Show("请输入供应商名称!", "提示信息", MessageBoxIcon.Warning); return; } if ((DbHelperOra.Exists("select 1 from DOC_SUPPLIER where SUPID = '" + tbxSUPID.Text + "'")) && (tbxSUPID.Enabled)) { Alert.Show("此供应商编码已经存在,请重新输入!", "提示信息", MessageBoxIcon.Warning); return; } if (hfdIsNew.Text == "N") { if (DbHelperOra.Exists("SELECT 1 FROM DOC_SUPPLIER WHERE SUPNAME = '" + tbxSUPNAME.Text + "'")) { Alert.Show("供应商名称已存在,请重新输入!", "提示信息", MessageBoxIcon.Warning); return; } } mtType.ColRow = PubFunc.FormDataHT(FormProducer); mtType.ColRow.Add("SUPCAT", "03"); mtType.ColRow["ISSEND"] = chkSTR1.Checked ? "N" : "Y"; mtType.ColRow["ISDG"] = chkSTR1.Checked ? "Y" : "N"; mtType.ColRow["FLAG"] = "Y"; mtType.InsertExec(); GridInTo(); }
/// <summary> /// It is assumed that the table "tableToReplace" contains columns with headers "NameOfField" and "Description". The method puts into lists "names" and "descriptions" the content of columns with those headers. /// </summary> /// <param mainFile="tableToReplace"></param> /// <param mainFile="names"></param> /// <param mainFile="descriptions"></param> public static void NameDescriptionDictionary(ref MyTable tableToReplace, ref List <string> names, ref List <string> descriptions) { tableToReplace.GiveColumn(TablesFieldsEnum.NameOfField.ToString(), ref names); tableToReplace.GiveColumn(TablesFieldsEnum.Description.ToString(), ref descriptions); }
private void save(string flag = "Y") { #region 数据有效性验证 if ((",M,R").IndexOf(docFLAG.SelectedValue) < 0) { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } if (PubFunc.FormDataCheck(FormDoc).Length > 0) { return; } List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行、批号填写是否符合要求 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString()) && !string.IsNullOrWhiteSpace(newDict[i]["GDNAME"].ToString())) { //填写商品追溯码时,使用数必须为小于等于1 if (newDict[i]["NUM1"].ToString() == newDict[i]["NUM2"].ToString()) { Alert.Show("商品【" + newDict[i]["GDNAME"].ToString() + "】调整与原设定相同,请检查!", "提示信息", MessageBoxIcon.Warning); return; } goodsData.Add(newDict[i]); } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } #endregion if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docBILLNO.Text = BillSeqGet(); docBILLNO.Enabled = false; } else { string flg = (string)DbHelperOra.GetSingle(string.Format("SELECT NVL(FLAG,'M') FROM DAT_DT_DOC WHERE SEQNO='{0}'", docBILLNO.Text)); if (!string.IsNullOrWhiteSpace(flg) && (",M,R").IndexOf(flg) < 0) { Alert.Show("您输入的单据号存在重复信息,请重新输入或置空!", "消息提示", MessageBoxIcon.Warning); return; } else { docBILLNO.Enabled = false; } } MyTable mtType = new MyTable("DAT_DT_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow["FLAG"] = "M"; mtType.ColRow.Add("BILLTYPE", BillType); mtType.ColRow.Add("SUBNUM", goodsData.Count); mtType.ColRow.Add("XSTYPE", "1"); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_DT_COM"); //先删除单据信息在插入 cmdList.Add(new CommandInfo("delete DAT_DT_DOC where seqno='" + docBILLNO.Text + "'", null)); //删除单据台头 cmdList.Add(new CommandInfo("delete DAT_DT_COM where seqno='" + docBILLNO.Text + "'", null)); //删除单据明细 for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); cmdList.Add(mtTypeMx.Insert()); } cmdList.AddRange(mtType.InsertCommand()); //增加待办事宜 cmdList.Add(Doc.GETDOADD("DO_13", docDEPTID.SelectedValue, docLRY.SelectedValue, docBILLNO.Text.Trim())); if (DbHelperOra.ExecuteSqlTran(cmdList)) { Alert.Show("高值修改信息保存成功!"); OperLog("高值调整", "修改单据【" + docBILLNO.Text + "】"); billOpen(docBILLNO.Text); } SaveSuccess = true; }
public void AddFoo() { var myTable = new MyTable(); myTable.PopulateFromType(typeof(Foo)); }
protected void btnCreate_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(docDEPTID.SelectedValue)) { Alert.Show("没有选择【库房】,不能生成养护单。"); return; } if (GridLeft.SelectedRowIndexArray.Length < 1) { Alert.Show("请选择需要生成的单据信息!", "提示信息", MessageBoxIcon.Warning); return; } string strSeqNo = BillSeqGet(); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtType = new MyTable("DAT_YH_DOC"); mtType.ColRow["SEQNO"] = strSeqNo; mtType.ColRow["BILLNO"] = strSeqNo; mtType.ColRow["BILLTYPE"] = BillType.ToString(); mtType.ColRow["FLAG"] = "M"; mtType.ColRow["DEPTID"] = docDEPTID.SelectedValue; mtType.ColRow["YHRQ"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); mtType.ColRow["SUBNUM"] = GridLeft.SelectedRowIndexArray.Length; mtType.ColRow["YHY"] = UserAction.UserID; mtType.ColRow["LRY"] = UserAction.UserID; mtType.ColRow["LRRQ"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); MyTable mtTypeMx = new MyTable("DAT_YH_COM"); //先删除单据信息在插入 int i = 0; decimal decTotal = 0; foreach (int index in GridLeft.SelectedRowIndexArray) { Hashtable row = PubFunc.GridDataGet(GridLeft.Rows[index]); mtTypeMx.ColRow["SEQNO"] = strSeqNo; mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow["GDSEQ"] = row["GDSEQ"]; mtTypeMx.ColRow["GDID"] = row["GDID"]; mtTypeMx.ColRow["GDNAME"] = row["GDNAME"]; mtTypeMx.ColRow["GDSPEC"] = row["GDSPEC"]; mtTypeMx.ColRow["UNIT"] = row["UNIT"]; mtTypeMx.ColRow["ISGZ"] = row["ISGZ"]; mtTypeMx.ColRow["ISLOT"] = row["ISLOT"]; mtTypeMx.ColRow["HSJJ"] = row["HSJJ"]; mtTypeMx.ColRow["KCSL"] = row["KCSL"]; mtTypeMx.ColRow["HSJE"] = row["HSJE"]; mtTypeMx.ColRow["STR1"] = row["HWID"]; mtTypeMx.ColRow["PHID"] = row["PHID"]; mtTypeMx.ColRow["YXQZ"] = row["YXQZ"]; mtTypeMx.ColRow["RQ_SC"] = row["RQ_SC"]; mtTypeMx.ColRow["HWID"] = row["HWID"]; mtTypeMx.ColRow["GDMODE"] = row["GDMODE"]; mtTypeMx.ColRow["BZHL"] = row["BZHL"]; mtTypeMx.ColRow["PIZNO"] = row["PIZNO"]; mtTypeMx.ColRow["PRODUCER"] = row["PRODUCER"]; mtTypeMx.ColRow["ZPBH"] = row["ZPBH"]; mtTypeMx.ColRow["MEMO"] = row["MEMO"]; mtTypeMx.ColRow["PICINO"] = row["PICINO"]; decTotal += decimal.Parse(row["HSJE"].ToString()); i++; cmdList.Add(mtTypeMx.Insert()); } mtType.ColRow["SUBSUM"] = decTotal; cmdList.Add(mtType.Insert()); if (DbHelperOra.ExecuteSqlTran(cmdList)) { //PubFunc.FormDataClear(fmForm); Alert.Show("商品养护信息保存成功,已生成养护单【" + strSeqNo + "】!", "消息提示", MessageBoxIcon.Information); OperLog("在库养护", "生成单据【" + strSeqNo + "】"); } //docDEPTID.Enabled = true; TabStrip1.ActiveTabIndex = 1; btnSear_Click(null, null); }
/// <summary> /// See Algorithm 2. /// Learning FISMrmse by using SGD. /// </summary> /// <param name="train"></param> /// <param name="test"></param> /// <param name="epochs">maximum epochs</param> /// <param name="rho">#negative ratings / #postive ratings in sample negative samples</param> /// <param name="yita">learning rate</param> /// <param name="decay">decay for learning rate</param> /// <param name="alpha">power of the factor of x</param> /// <param name="beta">regularization parameter of P and Q</param> /// <param name="lambda">regularization parameter of bu</param> /// <param name="gamma">regularization parameter of bi</param> public void TrySGD(List <Rating> train, List <Rating> test, int epochs = 100, int rho = 1, double yita = 0.0001, double decay = 1.0, double alpha = 0.5, double beta = 2e-4, double gamma = 1e-4) { var sampledRatings = Tools.RandomSelectNegativeSamples(train, rho, false); var scoreBounds = Tools.GetMinAndMaxScore(sampledRatings); var userItemsTable = Tools.GetClassifiedUserItemsTable(sampledRatings); double loss = Loss(userItemsTable, beta, gamma); PrintParameters(sampledRatings, test, epochs, rho, yita, decay, alpha, beta, gamma, scoreBounds.Item1, scoreBounds.Item2); Console.WriteLine("epoch#loss(train),N,P,R,Coverage,Popularity,MAP"); MyTable ratingTable = Tools.GetRatingTable(train); int[] Ns = { 1, 5, 10, 15, 20, 25, 30 }; for (int epoch = 1; epoch <= epochs; epoch++) { foreach (int userId in userItemsTable.Keys) { var tuple = (Tuple <List <Rating>, List <Rating> >)userItemsTable[userId]; var positives = tuple.Item1; var negatives = tuple.Item2; //Tools.WriteRatings(positives, @"D:\p.csv"); //Tools.WriteRatings(negatives, @"D:\n.csv"); double factorOfX = Math.Pow(positives.Count - 1, -alpha); foreach (Rating i in positives) { UpdateT(i.UserId, positives, i.ItemId, factorOfX); // can be optimized double pui = Predict(i.UserId, i.ItemId); double[] x = new double[f]; // what is the problem? foreach (Rating j in negatives) { double puj = Predict(j.UserId, j.ItemId); double eij = (i.Score - j.Score) - (pui - puj); bi[i.ItemId] += yita * (eij - gamma * bi[i.ItemId]); bi[j.ItemId] -= yita * (eij - gamma * bi[j.ItemId]); for (int index = 0; index < f; index++) { Q[i.ItemId, index] += yita * (eij * T[i.UserId, index] - beta * Q[i.ItemId, index]); Q[j.ItemId, index] -= yita * (eij * T[j.UserId, index] - beta * Q[j.ItemId, index]); x[index] += eij * (Q[i.ItemId, index] - Q[j.ItemId, index]); } } //for (int index = 0; index < f; index++) //{ // P[i.ItemId, index] += yita * (factorOfX * x[index] / rho - beta * P[i.ItemId, index]); //} foreach (Rating k in positives) { if (k.ItemId != i.ItemId) { for (int index = 0; index < f; index++) { P[k.ItemId, index] += yita * (factorOfX * x[index] / rho - beta * P[k.ItemId, index]); } } } } } double lastLoss = Loss(userItemsTable, beta, gamma); if (epoch % 1 == 0 && epoch >= 1) { Console.Write("{0}#{1}", epoch, lastLoss); //Console.Write("{0}", epoch); List <Rating> recommendations = GetRecommendations(ratingTable, Ns[Ns.Length - 1]); // note that, the max K foreach (int n in Ns) { Console.Write(",{0}", n); List <Rating> subset = Tools.GetSubset(recommendations, n); var pr = Metrics.PrecisionAndRecall(subset, test); var cp = Metrics.CoverageAndPopularity(subset, train); var map = Metrics.MAP(subset, test, n); Console.WriteLine(",{0},{1},{2},{3},{4}", pr.Item1, pr.Item2, cp.Item1, cp.Item2, map); } } if (decay != 1.0) { gamma *= decay; } if (lastLoss < loss) { loss = lastLoss; } else { break; } } }
/// <summary> /// Get relation tables /// 1. user - item - #tags /// 2. user - tag - #tags /// 3. item - tag - #tag /// </summary> /// <param name="recordTable"></param> /// <returns></returns> public static Tuple <List <Rating>, List <Link>, List <Link> > GetRelations(MyTable recordTable) { List <Rating> userItemCount = new List <Rating>(); // user - item - #tag List <Link> userTagCount = new List <Link>(); // user - tag - #tag List <Link> itemTagCount = new List <Link>(); // item - tag - #tag MyTable userTagTable = new MyTable(); MyTable itemTagTable = new MyTable(); foreach (int userId in recordTable.Keys) { Hashtable subTable = (Hashtable)recordTable[userId]; foreach (int itemId in subTable.Keys) { List <Link> links = (List <Link>)subTable[itemId]; Rating rating = new Rating(userId, itemId, links.Count); userItemCount.Add(rating); foreach (Link l in links) { // user - tag - # tags table //int itemId = l.From; int tagId = l.To; if (userTagTable.ContainsKey(userId, tagId)) { userTagTable[userId, tagId] = (int)userTagTable[userId, tagId] + 1; } else { userTagTable.Add(userId, tagId, 1); } // item - tag - #tags table if (itemTagTable.ContainsKey(itemId, tagId)) { itemTagTable[itemId, tagId] = (int)itemTagTable[itemId, tagId] + 1; } else { itemTagTable.Add(itemId, tagId, 1); } } } } foreach (int userId in userTagTable.Keys) { Hashtable subTable = (Hashtable)userTagTable[userId]; foreach (int tagId in subTable.Keys) { int counts = (int)subTable[tagId]; Link l = new Link(userId, tagId, counts); userTagCount.Add(l); } } // cull up for item - tag foreach (int itemId in itemTagTable.Keys) { Hashtable subTable = (Hashtable)itemTagTable[itemId]; foreach (int tagId in subTable.Keys) { int counts = (int)subTable[tagId]; Link l = new Link(itemId, tagId, counts); itemTagCount.Add(l); } } return(Tuple.Create(userItemCount, userTagCount, itemTagCount)); }
private void DataSave(string flag) { List <Dictionary <string, object> > goodsData = GridGoods.GetNewAddedList().ToList(); if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("没有任何数据!", "消息提示", MessageBoxIcon.Information); return; } if (!string.IsNullOrEmpty(docYSRQ.Text) && Convert.ToDateTime(docYSRQ.Text + "-01") < Convert.ToDateTime(DateTime.Now.AddMonths(1).ToString("yyyy-MM") + "-01")) { Alert.Show("当前时间只能做下一个月预算!", "消息提示", MessageBoxIcon.Information); return; } if (string.IsNullOrWhiteSpace(docSEQNO.Text)) { if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docSEQNO.Text = BillSeqGet(); docBILLNO.Text = docSEQNO.Text; docSEQNO.Enabled = false; } decimal bzslTotal = 0, feeTotal = 0; bzslTotal = goodsData.Count(); foreach (Dictionary <string, object> dic in goodsData) { if ((dic["HSJJ"] ?? "0").ToString().Length > 0) { feeTotal += Convert.ToDecimal(dic["HSJJ"] ?? "0") * Convert.ToDecimal(dic["YSSL"] ?? "0"); } } MyTable mtType = new MyTable("DAT_YS_DOC"); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow["BILLNO"] = docBILLNO.Text; mtType.ColRow["FLAG"] = "M"; mtType.ColRow["BILLTYPE"] = "YSD"; //单据类别为预算单 mtType.ColRow["DEPTID"] = ddlDEPTID.SelectedValue; mtType.ColRow["YSRANGE"] = Convert.ToDecimal(nbxYSSL.Text); //插入预算调整幅度 mtType.ColRow["BEGRQ"] = dpStartDate.SelectedDate; mtType.ColRow["ENDRQ"] = dpEndDate.SelectedDate; mtType.ColRow["YSRQ"] = docYSRQ.Text; mtType.ColRow["SUBNUM"] = bzslTotal.ToString(); mtType.ColRow["SUBSUM"] = feeTotal.ToString("F2"); mtType.ColRow["YSY"] = UserAction.UserID; mtType.ColRow["LRY"] = UserAction.UserID; mtType.ColRow["LRRQ"] = DateTime.Now; mtType.ColRow["SPR"] = UserAction.UserID; mtType.ColRow["SPRQ"] = DateTime.Now; mtType.ColRow["SHR"] = ""; mtType.ColRow["SHRQ"] = ""; mtType.ColRow["MEMO"] = docMEMO.Text; List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_YS_COM"); cmdList.Add(new CommandInfo("DELETE DAT_YS_COM WHERE SEQNO='" + docBILLNO.Text + "'", null)); //删除单据台头 cmdList.Add(new CommandInfo("DELETE DAT_YS_COM WHERE SEQNO='" + docBILLNO.Text + "'", null)); //删除单据明细 cmdList.AddRange(mtType.InsertCommand()); for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow.Add("ROWNO", i + 1); mtTypeMx.ColRow.Add("BZHL", 0); mtTypeMx.ColRow.Remove("HSJE"); mtTypeMx.ColRow.Add("HSJE", Convert.ToDecimal(goodsData[i]["HSJJ"] ?? "0") * Convert.ToDecimal(goodsData[i]["YSSL"] ?? "0")); cmdList.Add(mtTypeMx.Insert()); } if (DbHelperOra.ExecuteSqlTran(cmdList)) { Alert.Show("预算单生成成功!!", "消息提示", MessageBoxIcon.Information); billOpen(docBILLNO.Text); OperLog("科室预算", "生成单据【" + docBILLNO.Text + "】"); btnSave.Enabled = true; btnSumbit.Enabled = true; btnPrint.Enabled = false; btnExport.Enabled = false; //btnDelRow.Enabled = false; } else { Alert.Show("预算单生成失败!", "消息提示", MessageBoxIcon.Information); btnSave.Enabled = true; return; } } else { int mycount = 0; int RowNum = goodsData.Count; Decimal CountNum = 0; for (int i = 0; i < goodsData.Count; i++) { string ss = goodsData[i]["YSSL"].ToString(); string hsje = goodsData[i]["HSJE"].ToString(); CountNum += Convert.ToDecimal(goodsData[i]["HSJE"] ?? 0); string comsql = string.Format("update dat_ys_COM com set YSSL={0},HSJE={1} where com.seqno='{2}' and com.rowno={3}", Convert.ToDecimal(ss), Convert.ToDecimal(hsje), docSEQNO.Text, i + 1); mycount = DbHelperOra.ExecuteSql(comsql); } string mysql = string.Format("update dat_ys_doc set DEPTID='{0}',YSRANGE={1},memo='{2}' ,SubNum={3},SubSum={4} where seqno='{5}'", ddlDEPTID.SelectedValue, Convert.ToDecimal(nbxYSSL.Text), docMEMO.Text, RowNum, CountNum, docSEQNO.Text); int count = DbHelperOra.ExecuteSql(mysql); if (count > 0 && mycount > 0) { if (flag == "N") { Alert.Show("预算单修改成功!", "消息提示", MessageBoxIcon.Information); } OperLog("科室预算", "修改单据【" + docBILLNO.Text + "】"); billOpen(docBILLNO.Text); btnSave.Enabled = true; btnSumbit.Enabled = true; btnPrint.Enabled = false; btnExport.Enabled = false; btnDelRow.Enabled = false; } else { Alert.Show("预算单修改失败,请检查原因!", "消息提示", MessageBoxIcon.Information); btnSave.Enabled = true; hfdFlag.Text = "false"; } } }
protected void btnSave_Click(object sender, EventArgs e) { if (PubFunc.FormDataCheck(FormConfig).Length > 1) { return; } if (tbnZDKC.Text.Length > 0 && tbnZGKC.Text.Length > 0) { if (Convert.ToDecimal(tbnZDKC.Text) > Convert.ToDecimal(tbnZGKC.Text)) { Alert.Show("最低库存不能大于最高库存"); return; } } //填写定数数量,定数系数必须填写 //if (nbxDSNUM.Text.Length > 0) //{ // if (NubNUM1.Text.Length < 1) // { // Alert.Show("定数数量不为0时,定数系数必须填写!"); // return; // } // if (Convert.ToDecimal(nbxDSNUM.Text) > 0 && Convert.ToDecimal(NubNUM1.Text) < 1) // { // Alert.Show("定数数量不为0时,定数系数必须填写!"); // return; // } //} MyTable mtType = new MyTable("DOC_GOODSCFG"); mtType.ColRow = PubFunc.FormDataHT(FormConfig); mtType.ColRow.Remove("GDNAME"); string strISCFG = ""; if (chkISCFGID.Checked) { strISCFG = "Y"; } else { strISCFG = "N"; } mtType.ColRow.Add("ISCFG", strISCFG); mtType.UpdateExec(); //同步修改库存表中存在库存信息 //if (DbHelperOra.Exists("SELECT 1 FROM SYS_DEPT WHERE CODE = '" + ddlDept.SelectedValue + "' AND TYPE IN('1','2')") && cbxTB.Checked) //{ if (trbHJCODE1.Text.Trim().Length < 1) { Alert.Show("请维护库房商品【" + tbxGDSEQ.Text + "】的货位信息!", "操作提示", MessageBoxIcon.Warning); return; } if (cbxTB.Checked) { DbHelperOra.ExecuteSql("UPDATE DAT_GOODSSTOCK SET HWID = '" + trbHJCODE1.Text + "' WHERE GDSEQ = '" + tbxGDSEQ.Text + "' AND DEPTID = '" + ddlDept.SelectedValue + "'"); } OperLog("商品配置", "修改科室【" + ddlDept.SelectedValue + "】商品【" + tbxGDSEQ.Text + "】"); //} //else //{ // Alert.Show("这个是科室,直接把科室编码冻结"); //} dataSearch(); dataSearch("right"); Alert.Show("配置信息保存成功!"); //PubFunc.FormDataClear(FormConfig); //cbxTB.Checked = true; }
protected bool DataSave(string flag = "N") { if (docFLAG.SelectedValue != "N") { Alert.Show("非[已提交]不能保存!", "消息提示", MessageBoxIcon.Warning); return(false); } List <Dictionary <string, object> > goodsData = GridLis.GetNewAddedList().OrderBy(x => x["GDSEQ"]).ToList(); if (goodsData.Count < 1) { Alert.Show("请添加要生成养护单的商品信息!", "提示信息", MessageBoxIcon.Warning); return(false); } List <CommandInfo> cmdList = new List <CommandInfo>(); if (PubFunc.StrIsEmpty(docSEQNO.Text)) { docSEQNO.Text = BillSeqGet(); docBILLNO.Text = docSEQNO.Text; } else { if (docBILLNO.Text.Length > 16) { Alert.Show("单据编号长度不能大于16,请检查!", "消息提示", MessageBoxIcon.Warning); return(false); } docSEQNO.Text = docBILLNO.Text; } cmdList.Add(new CommandInfo("delete from dat_yh_doc where seqno='" + docSEQNO.Text + "'", null)); cmdList.Add(new CommandInfo("delete from dat_yh_com where seqno='" + docSEQNO.Text + "'", null)); MyTable mtType = new MyTable("DAT_YH_DOC"); mtType.ColRow = PubFunc.FormDataHT(Formlis); mtType.ColRow.Add("BILLTYPE", BillType); decimal decTotal = 0; MyTable mtTypeMx = new MyTable("DAT_YH_COM"); //先删除单据信息在插入 for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); if (mtTypeMx.ColRow["REASON"].ToString().Length > 80) { Alert.Show("第【" + i + 1 + "】行【原因说明】字段超出规定长度"); return(false); } mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Add("PH", mtTypeMx.ColRow["PHID"]); decTotal += decimal.Parse(mtTypeMx.ColRow["HSJE"].ToString()); mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); cmdList.Add(mtTypeMx.Insert()); } mtType.ColRow.Add("SUBNUM", goodsData.Count); mtType.ColRow.Add("SUBSUM", decTotal); if (flag == "Y") { mtType.ColRow["FLAG"] = "Y"; //mtType.ColRow["SHR"] = ddlSHR.SelectedValue; mtType.ColRow["SHR"] = UserAction.UserID; mtType.ColRow["SHRQ"] = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now); } cmdList.Add(mtType.Insert()); return(DbHelperOra.ExecuteSqlTran(cmdList)); }
/// <summary> /// too long time to run a result /// </summary> /// <param name="train"></param> /// <param name="test"></param> /// <param name="links"></param> /// <param name="epochs"></param> /// <param name="gamma"></param> /// <param name="lambda"></param> /// <param name="decay"></param> /// <param name="minimumRating"></param> /// <param name="maximumRating"></param> public void TrySGDForTopN(List <Rating> train, List <Rating> test, List <Link> links, int epochs = 100, double gamma = 0.01, double lambda = 0.01, double decay = 1.0, double minimumRating = 1.0, double maximumRating = 5.0) { PrintParameters(train, test, links, epochs, gamma, lambda, decay, minimumRating, maximumRating); Hashtable userItemsTable = Tools.GetUserItemsTable(train); Hashtable userLinksTable = Tools.GetUserLinksTable(links); MyTable ratingTable = Tools.GetRatingTable(train); int[] K = { 1, 5, 10, 15, 20, 25, 30 }; // recommdation list UpdateX(userLinksTable); double loss = Loss(train, lambda); for (int epoch = 1; epoch <= epochs; epoch++) { // UpdateX(userLinksTable, w); foreach (int uId in userItemsTable.Keys) { if (userLinksTable.ContainsKey(uId)) { List <Link> _links = (List <Link>)userLinksTable[uId]; UpdateX(uId, _links); } List <Rating> ratings = (List <Rating>)userItemsTable[uId]; // ratings with an UserId foreach (Rating r in ratings) { double pui = Predict(r.UserId, r.ItemId); double eui = r.Score - pui; for (int i = 0; i < f; i++) { P[r.UserId, i] += gamma * (eui * (Q[r.ItemId, i] + X[r.UserId, i]) - lambda * P[r.UserId, i]); Q[r.ItemId, i] += gamma * (eui * P[r.UserId, i] - lambda * Q[r.ItemId, i]); } // update W_u double _sum = 0.0; for (int i = 0; i < f; i++) { _sum += X[uId, i] * P[uId, i]; } if (_sum != 0) { W[uId] += gamma * (eui * _sum - lambda * W[uId]); } } } double lastLoss = Loss(train, lambda); if (epoch % 2 == 0 && epoch >= 20) { Console.Write("{0}#{1}", epoch, lastLoss); List <Rating> recommendations = GetRecommendations(ratingTable, K[K.Length - 1], true); // note that, the max K foreach (int k in K) { Console.Write(",{0}", k); List <Rating> subset = Tools.GetSubset(recommendations, k); var pr = Metrics.PrecisionAndRecall(subset, test); var cp = Metrics.CoverageAndPopularity(subset, train); var map = Metrics.MAP(subset, test, k); Console.WriteLine(",{0},{1},{2},{3},{4}", pr.Item1, pr.Item2, cp.Item1, cp.Item2, map); } } if (decay != 1.0) { gamma *= decay; } if (lastLoss < loss) { loss = lastLoss; } else { break; } } }
protected override void billSave() { #region 数据有效性验证 if (("MR").IndexOf(docFLAG.SelectedValue) < 0) { Alert.Show("非新单不能保存!", "消息提示", MessageBoxIcon.Warning); return; } if (!CheckFlagForM() && !CheckFlagForR()) { Alert.Show("此单据已经被别人操作,请等待操作!"); return; } if (!docBILLNO.Text.Contains(BillType) && docBILLNO.Text.Length > 0) { Alert.Show("下传单据不能保存!", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > goodsData = GridCom.GetNewAddedList(); if (goodsData.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } if (PubFunc.FormDataCheck(FormDoc).Length > 0) { return; } if (docDHRQ.SelectedDate == null) { Alert.Show("收货日期输入错误!"); return; } string type = DbHelperOra.GetSingle(string.Format("select TYPE from SYS_DEPT where CODE='{0}'", docDEPTID.SelectedValue)).ToString(); List <Dictionary <string, object> > newDict = new List <Dictionary <string, object> >(); //判断是否有空行、批号填写是否符合要求 for (int i = 0; i < goodsData.Count; i++) { if (!string.IsNullOrWhiteSpace(goodsData[i]["GDSEQ"].ToString()) && !string.IsNullOrWhiteSpace(goodsData[i]["GDNAME"].ToString())) { if ((goodsData[i]["BZSL"] ?? "").ToString() == "" || (goodsData[i]["BZSL"] ?? "").ToString() == "0") { Alert.Show("请填写商品[" + goodsData[i]["GDSEQ"] + "]入库数!", "消息提示", MessageBoxIcon.Warning); return; } if ((goodsData[i]["HSJJ"] ?? "").ToString() == "" || (goodsData[i]["HSJJ"] ?? "").ToString() == "0" || Convert.ToDecimal(goodsData[i]["HSJJ"]) == 0) { Alert.Show("商品[" + goodsData[i]["GDSEQ"] + "]的【含税进价】不能为零,请维护好商品的含税进价,再次保存!", "消息提示", MessageBoxIcon.Warning); return; } //当入库部门为1药库、2药房时 if ((",1,2").IndexOf(type) > 0 && string.IsNullOrWhiteSpace(goodsData[i]["HWID"].ToString())) { Alert.Show("第[" + (i + 1) + "]行商品【" + goodsData[i]["GDNAME"].ToString() + "】货位不能为空!!!", "消息提示", MessageBoxIcon.Warning); return; } else { if (string.IsNullOrWhiteSpace(goodsData[i]["HWID"].ToString())) { goodsData[i]["HWID"] = docDEPTID.SelectedValue; } } newDict.Add(goodsData[i]); } } if (newDict.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息不能为空", "消息提示", MessageBoxIcon.Warning); return; } #endregion if (PubFunc.StrIsEmpty(docBILLNO.Text)) { docSEQNO.Text = BillSeqGet(); docBILLNO.Text = docSEQNO.Text; docBILLNO.Enabled = false; } else { string flg = (string)DbHelperOra.GetSingle(string.Format("SELECT NVL(FLAG,'M') FROM DAT_YRK_DOC WHERE SEQNO='{0}'", docBILLNO.Text)); if (!PubFunc.StrIsEmpty(flg) && (",M,R").IndexOf(flg) < 0) { Alert.Show("您输入的单据号存在重复信息,请重新输入或置空!", "消息提示", MessageBoxIcon.Warning); return; } else { docSEQNO.Text = docBILLNO.Text; docBILLNO.Enabled = false; } } if (docBILLNO.Text.Length > 15) { Alert.Show("单据编号输入超长,请检查!"); return; } MyTable mtType = new MyTable("DAT_YRK_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormDoc); mtType.ColRow["SEQNO"] = docBILLNO.Text; mtType.ColRow["FLAG"] = "M"; mtType.ColRow.Add("BILLTYPE", BillType); mtType.ColRow.Add("SUBNUM", newDict.Count); mtType.ColRow.Add("PPSID", docPSSID.SelectedValue); //mtType.ColRow.Add("SUPNAME", docSUPID.SelectedText); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_YRK_COM"); //取消高值写入逻辑 //MyTable mtTypeExt = new MyTable("DAT_RK_EXT"); MyTable mtTypePh = new MyTable("DOC_GOODSPH"); decimal subNum = 0; //总金额 //先删除单据信息在插入 cmdList.Add(new CommandInfo("delete DAT_YRK_DOC where seqno='" + docBILLNO.Text + "'", null)); //删除单据台头 cmdList.Add(new CommandInfo("delete DAT_YRK_COM where seqno='" + docBILLNO.Text + "'", null)); //删除单据明细 newDict = newDict.OrderBy(x => x["GDSEQ"]).ToList(); //按照商品编码重新排序 for (int i = 0; i < newDict.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(newDict[i]); mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow.Add("ROWNO", i + 1); mtTypeMx.ColRow.Add("PHID", mtTypeMx.ColRow["PH"]); mtTypeMx.ColRow.Add("BHSJJ", 0); mtTypeMx.ColRow.Add("BHSJE", 0); mtTypeMx.ColRow.Add("SSSL", 0); mtTypeMx.ColRow["HSJE"] = decimal.Parse(mtTypeMx.ColRow["HSJJ"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()); subNum = subNum + decimal.Parse(mtTypeMx.ColRow["HSJE"].ToString()); mtTypeMx.ColRow["DDSL"] = decimal.Parse(mtTypeMx.ColRow["BZHL"].ToString()) * decimal.Parse(mtTypeMx.ColRow["BZSL"].ToString()); string codeInfo = newDict[i]["CODEINFO"].ToString(); mtTypeMx.ColRow.Remove("CODEINFO"); cmdList.Add(mtTypeMx.Insert()); } mtType.ColRow.Add("SUBSUM", subNum); if (PubFunc.StrIsEmpty(mtType.ColRow["NUM1"].ToString())) { mtType.ColRow.Remove("NUM1"); } cmdList.AddRange(mtType.InsertCommand()); if (DbHelperOra.ExecuteSqlTran(cmdList)) { Alert.Show("商品入库数据保存成功!"); billOpen(docBILLNO.Text); billLockDoc(true); OperLog("跟台商品入库", "修改单据【" + docBILLNO.Text + "】"); } else { Alert.Show("商品入库数据保存失败!", "错误提示", MessageBoxIcon.Error); } }
protected override void billSave() { List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList(); if (newDict.Count == 0) { Alert.Show("请输入商品信息", "消息提示", MessageBoxIcon.Warning); return; } List <Dictionary <string, object> > goodsData = new List <Dictionary <string, object> >(); //判断是否有空行 for (int i = 0; i < newDict.Count; i++) { if (!string.IsNullOrWhiteSpace(newDict[i]["GDSEQ"].ToString()) && !string.IsNullOrWhiteSpace(newDict[i]["GDNAME"].ToString())) { if ((newDict[i]["XHSJJ"] ?? "").ToString().Length > 0) { if (PubFunc.StrIsEmpty(newDict[i]["UNIT"].ToString()) || !PubFunc.isNumeric(newDict[i]["XHSJJ"].ToString())) { Alert.Show("商品【" + newDict[i]["GDSEQ"] + "】信息异常,请详细检查商品信息:包装单位或价格!", "异常信息", MessageBoxIcon.Warning); return; } //原价格与现价格不能相同 if (newDict[i]["XHSJJ"].ToString() == (newDict[i]["HSJJ"] ?? "").ToString()) { Alert.Show("商品【" + newDict[i]["GDSEQ"] + "】原价格与调整价格相同,请检查!", "异常信息", MessageBoxIcon.Warning); return; } } else { Alert.Show("请维护商品【" + newDict[i]["GDSEQ"] + "】修改后价格!", "异常信息", MessageBoxIcon.Warning); return; } goodsData.Add(newDict[i]); } } if (goodsData.Count == 0)//所有Gird行都为空行时 { Alert.Show("商品信息异常,请详细检查商品信息!", "消息提示", MessageBoxIcon.Warning); return; } if (PubFunc.StrIsEmpty(hfdSEQNO.Text)) { hfdSEQNO.Text = BillSeqGet(); docBILLNO.Text = hfdSEQNO.Text; docBILLNO.Enabled = false; } else { if (hfdSEQNO.Text.Length > 16 || docBILLNO.Text.Length > 16) { Alert.Show("单据编号长度不能大于16,请检查!", "消息提示", MessageBoxIcon.Warning); return; } string flg = (string)DbHelperOra.GetSingle(string.Format("SELECT NVL(FLAG,'M') FROM DAT_TJ_DOC WHERE SEQNO='{0}'", docBILLNO.Text)); if (!PubFunc.StrIsEmpty(flg) && (",M,R").IndexOf(flg) < 0) { Alert.Show("您输入的单据号存在重复信息,请重新输入或置空!", "消息提示", MessageBoxIcon.Warning); return; } else { docBILLNO.Text = hfdSEQNO.Text; docBILLNO.Enabled = false; } } MyTable mtType = new MyTable("DAT_TJ_DOC"); mtType.ColRow = PubFunc.FormDataHT(FormPrice); mtType.ColRow["FLAG"] = "M";//所有单据在保存时单据状态一律为新增M mtType.ColRow.Add("BILLTYPE", BillType); mtType.ColRow.Add("SUBNUM", goodsData.Count); List <CommandInfo> cmdList = new List <CommandInfo>(); MyTable mtTypeMx = new MyTable("DAT_TJ_COM"); //先删除单据信息在插入 cmdList.Add(new CommandInfo("DELETE DAT_TJ_DOC WHERE SEQNO='" + docBILLNO.Text + "'", null)); //删除单据台头 cmdList.Add(new CommandInfo("DELETE DAT_TJ_COM WHERE SEQNO='" + docBILLNO.Text + "'", null)); //删除单据明细 cmdList.AddRange(mtType.InsertCommand()); for (int i = 0; i < goodsData.Count; i++) { mtTypeMx.ColRow = PubFunc.GridDataGet(goodsData[i]); mtTypeMx.ColRow.Add("SEQNO", docBILLNO.Text); mtTypeMx.ColRow["ROWNO"] = i + 1; mtTypeMx.ColRow.Remove("UNITNAME"); mtTypeMx.ColRow.Remove("PRODUCERNAME"); cmdList.Add(mtTypeMx.Insert()); } if (DbHelperOra.ExecuteSqlTran(cmdList)) { btnSubmit.Enabled = true; Alert.Show("商品价格修改信息保存成功!", "消息提示", MessageBoxIcon.Information); OperLog("商品调价", "修改单据【" + docBILLNO.Text + "】"); billOpen(docBILLNO.Text); } else { Alert.Show("商品价格修改信息保存失败,请联系管理员!", "消息提示", MessageBoxIcon.Error); } }
private void saveExec() { try { if (PubFunc.FormDataCheck(FormProducer).Length > 0) { return; //存在为空的非空列则返回! } //增加自动生成的编码 if (hfdIsNew.Text == "Y" && tbxSUPID.Text.Trim().Length < 1) { DataTable dt = DbHelperOra.QueryForTable("SELECT F_GET_SUPCODE FROM DUAL"); if (dt.Rows.Count > 0) { tbxSUPID.Text = dt.Rows[0][0].ToString(); } if (string.IsNullOrEmpty(tbxSUPID.Text))//当导入供应商时,SUPID再次新增时,超过50次尝试后无法自动生成 { string getstring = DbHelperOra.GetSingle("SELECT SUPID FROM(SELECT SUPID FROM DOC_SUPPLIER ORDER BY SUPID DESC) WHERE ROWNUM=1 ").ToString(); int totalcount = 0; int zerocount = 0; string newstring = ""; MatchCollection ms = Regex.Matches(getstring, @"\d+"); foreach (Match m in ms) { if (!string.IsNullOrEmpty(m.Value)) { totalcount = m.Value.Length; //总位数 zerocount = totalcount - Int32.Parse(m.Value).ToString().Length; //0的位数 newstring = (Int32.Parse(m.Value) + 1).ToString(); tbxSUPID.Text = getstring.Replace(m.Value, "") + m.Value.Substring(0, zerocount) + newstring; } } } } MyTable mtType = new MyTable("DOC_SUPPLIER"); if ((DbHelperOra.Exists("select 1 from DOC_SUPPLIER where SUPID = '" + tbxSUPID.Text + "'")) && (tbxSUPID.Enabled)) { Alert.Show("此供应商编码已经存在,请重新输入!", "提示信息", MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(hfdsavecount.Text)) { if (DbHelperOra.Exists("select 1 from DOC_SUPPLIER where SUPNAME = '" + tbxSUPNAME.Text + "'")) { Alert.Show("此供应商名称已经存在,请重新输入!", "提示信息", MessageBoxIcon.Warning); return; } } if (!chkISDG.Checked && chkSTR1.Checked) { Alert.Show("本地供应商必须为代管供应商!", "提示信息", MessageBoxIcon.Warning); chkISDG.Checked = true; return; } if (chkISSUPPLIER.Checked && chkISPSS.Checked) { Alert.Show("【供应商】标记与【配送商】标记不能同时维护!", "提示信息", MessageBoxIcon.Warning); return; } mtType.ColRow = PubFunc.FormDataHT(FormProducer); //mtType.ColRow.Add("FLAG", "N"); mtType.ColRow.Add("SUPCAT", "03"); if (hfdIsNew.Text == "" || hfdIsNew.Text == "Y") { mtType.ColRow["ISSEND"] = chkSTR1.Checked?"Y":"N"; mtType.InsertExec(); Alert.Show("数据保存成功!"); btnSave.Enabled = false; } else { if (string.IsNullOrWhiteSpace(tbxSUPPWD.Text.Trim())) { mtType.ColRow.Remove("SUPPWD"); } else { mtType.ColRow["SUPPWD"] = PasswordUtil.CreateDbPassword(tbxSUPPWD.Text.Trim()); } mtType.UpdateExec(""); Alert.Show("数据更新成功!"); } OperLog("供应商资料", "修改供应商【" + tbxSUPID.Text + "】"); } catch (Exception) { Alert.Show("请确认您的供应商名称是否重复了!"); } }