private void btnOpen_Click(object sender, EventArgs e) { try { string sql = @"select * from CaseNumber"; DataTable dt = db.ExecuteDataTable(sql, null); if (dt != null && dt.Rows.Count > 0) { if (!CheckLoginInfo()) { hkMain.Stop(); UserLogin loginFrm = new UserLogin(); loginFrm.LoginSelectionDelegate += delegate(int selection, string loginID) { if (selection == 1) { AddLoginInfo(loginID); hkMain.Stop(); CaseMgr caseMgrFrm = new CaseMgr(1); caseMgrFrm.Show(); } else { hkMain.Start(); //msgDialog.ShowMessage("登录失败", 1); } }; loginFrm.Show(); } else { hkMain.Stop(); CaseMgr caseMgrFrm = new CaseMgr(1); caseMgrFrm.Show(); } } else { msgDialog.ShowMessage("没有单据", 1); } } catch (Exception ex) { } }
public void DownloadDetailHandler(Scanner.CodeInfo obj) { #region 记录发货单条码 string sql = @"delete from AppConfig where Key=@Key"; SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@Key", "CaseBarcode"), new SQLiteParameter("@Value", obj.barcode) }; try { db.ExecuteNonQuery(sql, parameters); sql = @"insert into AppConfig(Key,Value) values(@Key,@Value)"; //parameters = new SQLiteParameter[]{ // new SQLiteParameter("@Key", "CaseBarcode"), // new SQLiteParameter("@Value", "0000000004-01") // }; db.ExecuteNonQuery(sql, parameters); } catch (Exception ex) { } #endregion #region 条码,下载发货单明细 if (D300SysUI.CheckNetworkStatus()) { string detailStrJson = DataUpDownload.DownloadInvoiceDetail(obj.barcode); FromERPJson model = JsonConvert.DeserializeObject <FromERPJson>(detailStrJson); if (model.IsSuccess) { msgDialog.ShowMessage("正在处理中,请稍后···", 1); sql = @"delete from FromERPDetail"; try { db.ExecuteNonQuery(sql, null); } catch (Exception ex) { } if (model.ReturnData.Count > 0) { bool isSuccess = false; using (SQLiteConnection connection = new SQLiteConnection(db.ConnectionString)) { connection.Open(); using (DbTransaction transaction = connection.BeginTransaction()) { using (SQLiteCommand command = new SQLiteCommand(connection)) { try { for (int i = 0; i < model.ReturnData.Count; i++) { command.CommandText = @"insert into FromERPDetail(InvoiceID,ProdID,Model,ProdName,Num,Barcode,BoxBarcode,NormNum,Title,bJianMaInBox,siteCode,ModType,ModID,DH) values (@InvoiceID,@ProdID,@Model,@ProdName,@Num,@Barcode,@BoxBarcode,@NormNum,@Title,@bJianMaInBox,@siteCode,@ModType,@ModID,@DH)"; parameters = new SQLiteParameter[] { new SQLiteParameter("@InvoiceID", model.ReturnData[i].InvoiceID), new SQLiteParameter("@ProdID", model.ReturnData[i].ProdID), new SQLiteParameter("@Model", model.ReturnData[i].Model), new SQLiteParameter("@ProdName", model.ReturnData[i].ProdName), new SQLiteParameter("@Num", model.ReturnData[i].Num), new SQLiteParameter("@Barcode", model.ReturnData[i].Barcode), new SQLiteParameter("@BoxBarcode", model.ReturnData[i].BoxBarcode), new SQLiteParameter("@NormNum", model.ReturnData[i].NormNum), new SQLiteParameter("@Title", model.ReturnData[i].Title), new SQLiteParameter("@bJianMaInBox", model.ReturnData[i].bJianMaInBox), new SQLiteParameter("@siteCode", model.ReturnData[i].siteCode), new SQLiteParameter("@ModType", model.ReturnData[i].ModType), new SQLiteParameter("@ModID", model.ReturnData[i].ModID), new SQLiteParameter("@DH", model.ReturnData[i].DH) }; if (parameters != null) { command.Parameters.AddRange(parameters); } command.ExecuteNonQuery(); } transaction.Commit(); isSuccess = true; } catch (Exception ex) { transaction.Rollback(); isSuccess = false; } } } } if (isSuccess) { CaseMgr caseMgrFrm = new CaseMgr(0); caseMgrFrm.Show(); } } } else { msgDialog.ShowMessage("没有该发货草稿单据", 1); } } else { msgDialog.ShowMessage("网络没有连接", 1); } #endregion }