public Guid GetNewID() { string strSql = @"declare @ID uniqueidentifier;set @ID=NewID(); select @ID as ID"; NewID result = _sqlconnnect.Query <NewID>(strSql).AsList().FirstOrDefault(); Guid ID = result.ID; return(ID); }
public override bool BeforeEndEdit() { //儲存前,再計算一次總金額 CalcTotals(); //檢視是否有輸入存貨異動明細 if (transferBindingSource.Count == 0) { MessageBox.Show("無存貨異動明細資料,無法儲存!", "儲存錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } //避免用戶偷跑 DataGridView Grid = transferDetailsDataGridView; for (int intRow = 0; intRow <= (Grid.Rows.Count - 2); intRow++) { if ((string)Grid.Rows[intRow].Cells["colProductID"].Value == null) { MessageBox.Show(String.Format( "第{0}筆存貨異動明細的商品編號必須要輸入。", Convert.ToString(intRow + 1)), "儲存錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } //新增模式產生存貨異動單號 if (TBStatus == 1) { //找出指定資料表的第一筆記錄 DateTime dt = Convert.ToDateTime(transferDateTextBox.Text); var rec = (from M in context.Transfer where M.TransferDate == dt orderby M.TransferID descending select M.TransferID).FirstOrDefault(); if (rec == null) { string tmpDate; tmpDate = Convert.ToDateTime( transferDateTextBox.Text).ToString("yy/MM/dd"); transferIDLabel.Text = tmpDate.Substring(0, 2) + tmpDate.Substring(3, 2) + tmpDate.Substring(6, 2) + "001"; } else { string NewID, OriginalID; OriginalID = rec; NewID = Convert.ToString( Convert.ToInt16(OriginalID.Substring(6, 3)) + 1); transferIDLabel.Text = OriginalID.Substring(0, 6) + NewID.PadLeft(3, '0'); } } //變更DataGridView控制項的虛擬模式 transferDetailsDataGridView.VirtualMode = false; return(true); }
public void Edit <T>(IAssetData asset) { IDictionary <string, string> BaseData = asset.AsDictionary <string, string>().Data; foreach (KeyValuePair <string, string> kvp in new Dictionary <string, string>(BaseData)) { if (ShuffleData.TryGetValue(int.Parse(kvp.Key), out int NewID)) { BaseData[NewID.ToString()] = kvp.Value; } else { BaseData[kvp.Key] = kvp.Value; } } }