public void CreateNewCard() { editableItem = (DeceasedCard)CreateNewItem(); ClearAllViews(); sqlmgr.Reconnect(); var res = sqlmgr.CreateNewEmptyCard(_currentUser.Id, _shift.CurrentShiftId); _card_id = res.Key; _shift_people = res.Value; DeceasedCard card = new DeceasedCard(); sqlmgr.GetCardAgents(card); ControlFiller.FillListControl((view_controls[3] as ListBox), card.Agents, null, false); sqlmgr.Disconnect(); ControlHelper.SetSelectedListControlItem((GetControlByName("DispetcherCB", true) as ComboBox), "Id", res.Value.DispetcherId); ControlHelper.SetSelectedListControlItem((GetControlByName("SmenaHelperCB", true) as ComboBox), "Id", res.Value.HelperId); ControlHelper.SetSelectedListControlItem((GetControlByName("DocumentsLinkerCB", true) as ComboBox), "Id", -1); }
public KeyValuePair<int, ShiftPeopleInfo> CreateNewEmptyCard(int user_id,int shift_id) { ShiftPeopleInfo spi = new ShiftPeopleInfo(); KeyValuePair<int, ShiftPeopleInfo> res;// = new KeyValuePair<int, ShiftPeopleInfo>(); spi.DispetcherId = user_id; //int helper_id = -1; _cmd = CreateCommand(string.Format("select sotr_id from ShiftUsers where shift_id={1} and sotr_id!={1}", shift_id.ToString(), user_id.ToString())); _DR = _cmd.ExecuteReader(); while (_DR.Read()) { spi.HelperId = (int)_DR["helper_id"]; break; } _DR.Close(); _cmd = CreateCommand(string.Format("insert into Cards(shift_id,Address,dead_fio,Comments,Result,Avans,created_user_id,helper_id,doc_linker_id,created_date) values({0},'','','',null,null,{1},{2},-1,getdate());", shift_id.ToString(), spi.DispetcherId.ToString(), spi.HelperId.ToString())); ExecuteCommand(_cmd.ExecuteNonQuery); var sqlres = decimal.ToInt32((decimal)ExecuteScalarCommand(CreateCommand("select @@identity").ExecuteScalar)); res = new KeyValuePair<int,ShiftPeopleInfo>(Convert.ToInt32(sqlres),spi); return res; }